灰色转RGB

    int GREY2RGB_TABLE[] = new int[]{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 17, 17, 18, 19, 20, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40, 41, 43, 44, 46, 48, 49, 51, 53, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 75, 77, 79, 81, 84, 86, 88, 91, 93, 96, 98, 101, 103, 106, 109, 111, 114, 116, 119, 122, 124, 127, 130, 132, 135, 138, 140, 143, 145, 148, 151, 153, 156, 158, 161, 163, 166, 168, 170, 173, 175, 177, 179, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 201, 203, 205, 206, 208, 210, 211, 213, 214, 215, 217, 218, 219, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 234, 235, 236, 237, 237, 238, 239, 239, 240, 240, 241, 241, 242, 242, 243, 243, 244, 244, 245, 245, 245, 246, 246, 246, 247, 247, 247, 248, 248, 248, 248, 249, 249, 249, 249, 250, 250, 250, 250, 250, 250, 251, 251, 251, 251, 251, 251, 251, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253};

    /**
     * 灰色数据转RGB值
     * @param buffer 灰色数据
     * @return
     */
    public static int[] toRGB(byte[] buffer){
        int[] data = new int[buffer.length];
        int alpha;
        for (int i = 0; i < buffer.length; i++) {
            int grey = 0x80 + buffer[i];
            grey = GREY2RGB_TABLE[grey];
            alpha = (grey == 127) ? 0 : 0xFF;
            data[i] = alpha << 24 | grey << 16 | grey << 8 | grey;
        }
        return data;
    }
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值