Fast and Accurate Color Depth Conversion - Full Table

 2bit Target3bit Target4bit Target5bit Target6bit Target7bit Target8bit Target9bit Target10bit Target11bit Target12bit Target13bit Target14bit Target15bit Target16bit Target
2bit Sourcex(x * 9 + 2) >> 2x * 5(x * 41 + 2) >> 2x * 21(x * 169 + 2) >> 2x * 85(x * 681 + 2) >> 2x * 341(x * 2729 + 2) >> 2x * 1365(x * 10921 + 2) >> 2x * 5461(x * 43689 + 2) >> 2x * 21845
3bit Source(x * 2 + 1) >> 2x(x * 17 + 4) >> 3(x * 18 + 1) >> 2x * 9(x * 145 + 4) >> 3(x * 146 + 1) >> 2x * 73(x * 1169 + 4) >> 3(x * 1170 + 1) >> 2x * 585(x * 9361 + 4) >> 3(x * 9362 + 1) >> 2x * 4681(x * 74897 + 4) >> 3
4bit Source(x * 3 + 9) >> 4(x * 2 + 1) >> 2x(x * 33 + 8) >> 4(x * 67 + 9) >> 4(x * 34 + 1) >> 2x * 17(x * 545 + 8) >> 4(x * 1091 + 9) >> 4(x * 546 + 1) >> 2x * 273(x * 8737 + 8) >> 4(x * 17475 + 9) >> 4(x * 8738 + 1) >> 2x * 4369
5bit Source(x * 13 + 56) >> 7(x * 15 + 23) >> 6(x * 2 + 1) >> 2x(x * 65 + 16) >> 5(x * 525 + 56) >> 7(x * 527 + 23) >> 6(x * 66 + 1) >> 2x * 33(x * 2113 + 16) >> 5(x * 16909 + 56) >> 7(x * 16911 + 23) >> 6(x * 2114 + 1) >> 2x * 1057(x * 67649 + 16) >> 5
6bit Source(x * 3 + 33) >> 6(x * 7 + 35) >> 6(x * 61 + 128) >> 8(x * 2 + 1) >> 2x(x * 129 + 32) >> 6(x * 259 + 33) >> 6(x * 519 + 35) >> 6(x * 4157 + 128) >> 8(x * 130 + 1) >> 2x * 65(x * 8321 + 32) >> 6(x * 16643 + 33) >> 6(x * 33287 + 35) >> 6(x * 266301 + 128) >> 8
7bit Source(x * 49 + 992) >> 11(x * 57 + 480) >> 10(x * 121 + 512) >> 10(x * 125 + 256) >> 9(x * 2 + 1) >> 2x(x * 257 + 64) >> 7(x * 8241 + 992) >> 11(x * 8249 + 480) >> 10(x * 16505 + 512) >> 10(x * 16509 + 256) >> 9(x * 258 + 1) >> 2x * 129(x * 33025 + 64) >> 7(x * 1056817 + 992) >> 11
8bit Source(x * 3 + 129) >> 8(x * 225 + 4096) >> 13(x * 15 + 135) >> 8(x * 249 + 1024) >> 11(x * 253 + 512) >> 10(x * 2 + 1) >> 2x(x * 513 + 128) >> 8(x * 1027 + 129) >> 8(x * 65761 + 4096) >> 13(x * 4111 + 135) >> 8(x * 65785 + 1024) >> 11(x * 65789 + 512) >> 10(x * 514 + 1) >> 2x * 257
9bit Source(x * 193 + 16256) >> 15(x * 7 + 259) >> 9(x * 241 + 3968) >> 13(x * 497 + 4096) >> 13(x * 505 + 2048) >> 12(x * 509 + 1024) >> 11(x * 2 + 1) >> 2x(x * 1025 + 256) >> 9(x * 131265 + 16256) >> 15(x * 4103 + 259) >> 9(x * 131313 + 3968) >> 13(x * 262641 + 4096) >> 13(x * 262649 + 2048) >> 12(x * 262653 + 1028) >> 11
10bit Source(x * 3 + 513) >> 10(x * 449 + 32512) >> 16(x * 961 + 32768) >> 16(x * 31 + 527) >> 10(x * 1009 + 8192) >> 14(x * 1017 + 4096) >> 13(x * 1021 + 2048) >> 12(x * 2 + 1) >> 2x(x * 2049 + 512) >> 10(x * 4099 + 513) >> 10(x * 524737 + 32512) >> 16(x * 1049537 + 32768) >> 16(x * 32799 + 527) >> 10(x * 1049585 + 8208) >> 14
11bit Source(x * 769 + 261632) >> 19(x * 1793 + 262144) >> 19(x * 1921 + 131072) >> 18(x * 993 + 32256) >> 16(x * 2017 + 32768) >> 16(x * 2033 + 16384) >> 15(x * 2041 + 8192) >> 14(x * 2045 + 4096) >> 13(x * 2 + 1) >> 2x(x * 4097 + 1024) >> 11
12bit Source(x * 3 + 2049) >> 12(x * 7 + 2051) >> 12(x * 15 + 2055) >> 12(x * 3969 + 262144) >> 19(x * 63 + 2079) >> 12(x * 4065 + 65536) >> 17(x * 4081 + 32768) >> 16(x * 4089 + 16384) >> 15(x * 4093 + 8192) >> 14(x * 2 + 1) >> 2x(x * 8193 + 2049) >> 12
13bit Source(x * 3073 + 4192256) >> 23(x * 3585 + 2095104) >> 22(x * 3841 + 1046528) >> 21(x * 7937 + 1048576) >> 21(x * 4033 + 260096) >> 19(x * 8129 + 262144) >> 19(x * 8161 + 131072) >> 18(x * 8177 + 65536) >> 17(x * 8185 + 32768) >> 16(x * 8189 + 16384) >> 15(x * 2 + 1) >> 2x
14bit Source(x * 3 + 8193) >> 14(x * 14337 + 16777216) >> 25(x * 15361 + 8388608) >> 24(x * 15873 + 4194304) >> 23(x * 16129 + 2097152) >> 22(x * 127 + 8255) >> 14(x * 16321 + 524288) >> 20(x * 16353 + 262144) >> 19(x * 16369 + 131072) >> 18(x * 16377 + 65536) >> 17(x * 16381 + 32772) >> 16(x * 2 + 1) >> 2x
15bit Source(x * 12289 + 67100672) >> 27(x * 7 + 16387) >> 15(x * 30721 + 33554432) >> 26(x * 31 + 16399) >> 15(x * 32257 + 8388608) >> 24(x * 16257 + 2088960) >> 22(x * 32641 + 2097152) >> 22(x * 32705 + 1048576) >> 21(x * 32737 + 524288) >> 20(x * 32753 + 262144) >> 19(x * 32761 + 131096) >> 18(x * 2 + 1) >> 2x
16bit Source(x * 3 + 32769) >> 16(x * 28673 + 134201344) >> 28(x * 15 + 32775) >> 16(x * 31745 + 33538048) >> 26(x * 255 + 32895) >> 16(x * 2 + 1) >> 2x

Leave a Reply