Skip to content

Commit fecb53b

Browse files
authored
Merge pull request #8837 from radarhere/bcn_decode
Do not convert BC1 LUT to UINT32
2 parents b8abded + 295a5e9 commit fecb53b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/libImaging/BcnDecode.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ typedef struct {
2525

2626
typedef struct {
2727
UINT16 c0, c1;
28-
UINT32 lut;
2928
} bc1_color;
3029

3130
typedef struct {
@@ -40,13 +39,10 @@ typedef struct {
4039

4140
#define LOAD16(p) (p)[0] | ((p)[1] << 8)
4241

43-
#define LOAD32(p) (p)[0] | ((p)[1] << 8) | ((p)[2] << 16) | ((p)[3] << 24)
44-
4542
static void
4643
bc1_color_load(bc1_color *dst, const UINT8 *src) {
4744
dst->c0 = LOAD16(src);
4845
dst->c1 = LOAD16(src + 2);
49-
dst->lut = LOAD32(src + 4);
5046
}
5147

5248
static rgba
@@ -70,7 +66,7 @@ static void
7066
decode_bc1_color(rgba *dst, const UINT8 *src, int separate_alpha) {
7167
bc1_color col;
7268
rgba p[4];
73-
int n, cw;
69+
int n, o, cw;
7470
UINT16 r0, g0, b0, r1, g1, b1;
7571
bc1_color_load(&col, src);
7672

@@ -103,9 +99,11 @@ decode_bc1_color(rgba *dst, const UINT8 *src, int separate_alpha) {
10399
p[3].b = 0;
104100
p[3].a = 0;
105101
}
106-
for (n = 0; n < 16; n++) {
107-
cw = 3 & (col.lut >> (2 * n));
108-
dst[n] = p[cw];
102+
for (n = 0; n < 4; n++) {
103+
for (o = 0; o < 4; o++) {
104+
cw = 3 & ((src + 4)[n] >> (2 * o));
105+
dst[n * 4 + o] = p[cw];
106+
}
109107
}
110108
}
111109

0 commit comments

Comments
 (0)