Skip to content

Some unpackers are misnamed #8021

@Yay295

Description

@Yay295

RGB15 actually reads data as XBGR (XBBBBBGGGGGRRRRR).

void
ImagingUnpackRGB15(UINT8 *out, const UINT8 *in, int pixels) {
int i, pixel;
/* RGB, 5 bits per pixel */
for (i = 0; i < pixels; i++) {
pixel = in[0] + (in[1] << 8);
out[R] = (pixel & 31) * 255 / 31;
out[G] = ((pixel >> 5) & 31) * 255 / 31;
out[B] = ((pixel >> 10) & 31) * 255 / 31;
out[A] = 255;
out += 4;
in += 2;
}
}

RGBA15 actually reads data as ABGR (ABBBBBGGGGGRRRRR).

void
ImagingUnpackRGBA15(UINT8 *out, const UINT8 *in, int pixels) {
int i, pixel;
/* RGB, 5/5/5/1 bits per pixel */
for (i = 0; i < pixels; i++) {
pixel = in[0] + (in[1] << 8);
out[R] = (pixel & 31) * 255 / 31;
out[G] = ((pixel >> 5) & 31) * 255 / 31;
out[B] = ((pixel >> 10) & 31) * 255 / 31;
out[A] = (pixel >> 15) * 255;
out += 4;
in += 2;
}
}

RGBA4B actually reads data as ABGR (AAAABBBBGGGGRRRR).

void
ImagingUnpackRGBA4B(UINT8 *out, const UINT8 *in, int pixels) {
int i, pixel;
/* RGBA, 4 bits per pixel */
for (i = 0; i < pixels; i++) {
pixel = in[0] + (in[1] << 8);
out[R] = (pixel & 15) * 17;
out[G] = ((pixel >> 4) & 15) * 17;
out[B] = ((pixel >> 8) & 15) * 17;
out[A] = ((pixel >> 12) & 15) * 17;
out += 4;
in += 2;
}
}

etc.

Basically, all of the unpackers that read less than 8 bits per band appear to be backwards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions