香农法诺生成位

时间:2016-05-09 13:58:12

标签: c# compression

我想用Shannon Fano压缩图像文件。图像用256个不同的字母编码。因此,这意味着我的表格大小为256.但我无法再获得8位长度的文件,文件将比旧版本大。 (2 ^ 8 = 256)

那么使用Shannon Fano有什么意义呢?我错过了什么?我的香农法诺代码:

import UIKit
@IBDesignable

class RoundShadowButton: UIButton {

    var backLayer: UIView!

    override func drawRect(rect: CGRect) {
        setup()
    }

    func setup() {
        backLayer = UIView()

        //add the subView
        backLayer?.bounds = bounds
        backLayer!.layer.cornerRadius = 10.0
        backLayer?.layer.masksToBounds = false
        backLayer!.layer.borderColor = UIColor.redColor().colorWithAlphaComponent(0.3).CGColor
        backLayer!.layer.borderWidth = 1.0
        backLayer.clipsToBounds = false
        addSubview(backLayer)

        //add shadow to layer of UIButton
        layer.shadowColor = UIColor.blackColor().CGColor
        imageEdgeInsets = UIEdgeInsetsMake(9, 32, 9, 32)
        layer.shadowOffset = CGSizeMake(0.0, 0.5)
        layer.shadowRadius = 1.0
        layer.shadowOpacity = 0.7
        layer.masksToBounds = false
        clipsToBounds = false
    }

0 个答案:

没有答案