Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/libImaging/BcnDecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ typedef struct {

typedef struct {
UINT16 c0, c1;
UINT32 lut;
} bc1_color;

typedef struct {
Expand All @@ -40,13 +39,10 @@ typedef struct {

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

#define LOAD32(p) (p)[0] | ((p)[1] << 8) | ((p)[2] << 16) | ((p)[3] << 24)

static void
bc1_color_load(bc1_color *dst, const UINT8 *src) {
dst->c0 = LOAD16(src);
dst->c1 = LOAD16(src + 2);
dst->lut = LOAD32(src + 4);
}

static rgba
Expand All @@ -70,7 +66,7 @@ static void
decode_bc1_color(rgba *dst, const UINT8 *src, int separate_alpha) {
bc1_color col;
rgba p[4];
int n, cw;
int n, o, cw;
UINT16 r0, g0, b0, r1, g1, b1;
bc1_color_load(&col, src);

Expand Down Expand Up @@ -103,9 +99,11 @@ decode_bc1_color(rgba *dst, const UINT8 *src, int separate_alpha) {
p[3].b = 0;
p[3].a = 0;
}
for (n = 0; n < 16; n++) {
cw = 3 & (col.lut >> (2 * n));
dst[n] = p[cw];
for (n = 0; n < 4; n++) {
for (o = 0; o < 4; o++) {
cw = 3 & ((src + 4)[n] >> (2 * o));
dst[n * 4 + o] = p[cw];
}
}
}

Expand Down
Loading