|
12 | 12 | #include "Imaging.h" |
13 | 13 |
|
14 | 14 | /* use make_hash.py from the pillow-scripts repository to calculate these values */ |
15 | | -#define ACCESS_TABLE_SIZE 27 |
16 | | -#define ACCESS_TABLE_HASH 33051 |
| 15 | +#define ACCESS_TABLE_SIZE 35 |
| 16 | +#define ACCESS_TABLE_HASH 8940 |
17 | 17 |
|
18 | 18 | static struct ImagingAccessInstance access_table[ACCESS_TABLE_SIZE]; |
19 | 19 |
|
@@ -87,6 +87,31 @@ get_pixel_16(Imaging im, int x, int y, void *color) { |
87 | 87 | memcpy(color, in, sizeof(UINT16)); |
88 | 88 | } |
89 | 89 |
|
| 90 | +static void |
| 91 | +get_pixel_BGR15(Imaging im, int x, int y, void *color) { |
| 92 | + UINT8 *in = (UINT8 *)&im->image8[y][x * 2]; |
| 93 | + UINT16 pixel = in[0] + (in[1] << 8); |
| 94 | + char *out = color; |
| 95 | + out[0] = (pixel & 31) * 255 / 31; |
| 96 | + out[1] = ((pixel >> 5) & 31) * 255 / 31; |
| 97 | + out[2] = ((pixel >> 10) & 31) * 255 / 31; |
| 98 | +} |
| 99 | + |
| 100 | +static void |
| 101 | +get_pixel_BGR16(Imaging im, int x, int y, void *color) { |
| 102 | + UINT8 *in = (UINT8 *)&im->image8[y][x * 2]; |
| 103 | + UINT16 pixel = in[0] + (in[1] << 8); |
| 104 | + char *out = color; |
| 105 | + out[0] = (pixel & 31) * 255 / 31; |
| 106 | + out[1] = ((pixel >> 5) & 63) * 255 / 63; |
| 107 | + out[2] = ((pixel >> 11) & 31) * 255 / 31; |
| 108 | +} |
| 109 | + |
| 110 | +static void |
| 111 | +get_pixel_BGR24(Imaging im, int x, int y, void *color) { |
| 112 | + memcpy(color, &im->image8[y][x * 3], sizeof(UINT8) * 3); |
| 113 | +} |
| 114 | + |
90 | 115 | static void |
91 | 116 | get_pixel_32(Imaging im, int x, int y, void *color) { |
92 | 117 | memcpy(color, &im->image32[y][x], sizeof(INT32)); |
@@ -134,6 +159,16 @@ put_pixel_16B(Imaging im, int x, int y, const void *color) { |
134 | 159 | out[1] = in[0]; |
135 | 160 | } |
136 | 161 |
|
| 162 | +static void |
| 163 | +put_pixel_BGR1516(Imaging im, int x, int y, const void *color) { |
| 164 | + memcpy(&im->image8[y][x * 2], color, 2); |
| 165 | +} |
| 166 | + |
| 167 | +static void |
| 168 | +put_pixel_BGR24(Imaging im, int x, int y, const void *color) { |
| 169 | + memcpy(&im->image8[y][x * 3], color, 3); |
| 170 | +} |
| 171 | + |
137 | 172 | static void |
138 | 173 | put_pixel_32L(Imaging im, int x, int y, const void *color) { |
139 | 174 | memcpy(&im->image8[y][x * 4], color, 4); |
@@ -178,6 +213,9 @@ ImagingAccessInit() { |
178 | 213 | ADD("F", get_pixel_32, put_pixel_32); |
179 | 214 | ADD("P", get_pixel_8, put_pixel_8); |
180 | 215 | ADD("PA", get_pixel_32_2bands, put_pixel_32); |
| 216 | + ADD("BGR;15", get_pixel_BGR15, put_pixel_BGR1516); |
| 217 | + ADD("BGR;16", get_pixel_BGR16, put_pixel_BGR1516); |
| 218 | + ADD("BGR;24", get_pixel_BGR24, put_pixel_BGR24); |
181 | 219 | ADD("RGB", get_pixel_32, put_pixel_32); |
182 | 220 | ADD("RGBA", get_pixel_32, put_pixel_32); |
183 | 221 | ADD("RGBa", get_pixel_32, put_pixel_32); |
|
0 commit comments