use mode structs in TiffDecode.c

This commit is contained in:
Yay295 2024-04-21 22:54:58 -05:00
parent 6f0ce3e876
commit 91776f2589
2 changed files with 12 additions and 12 deletions

View File

@ -79,11 +79,13 @@ extern const RawMode * const IMAGING_RAWMODE_1_IR;
extern const RawMode * const IMAGING_RAWMODE_1_R; extern const RawMode * const IMAGING_RAWMODE_1_R;
extern const RawMode * const IMAGING_RAWMODE_A; extern const RawMode * const IMAGING_RAWMODE_A;
extern const RawMode * const IMAGING_RAWMODE_ABGR; extern const RawMode * const IMAGING_RAWMODE_ABGR;
extern const RawMode * const IMAGING_RAWMODE_A_16N;
extern const RawMode * const IMAGING_RAWMODE_B; extern const RawMode * const IMAGING_RAWMODE_B;
extern const RawMode * const IMAGING_RAWMODE_BGR; extern const RawMode * const IMAGING_RAWMODE_BGR;
extern const RawMode * const IMAGING_RAWMODE_BGRA; extern const RawMode * const IMAGING_RAWMODE_BGRA;
extern const RawMode * const IMAGING_RAWMODE_BGRX; extern const RawMode * const IMAGING_RAWMODE_BGRX;
extern const RawMode * const IMAGING_RAWMODE_BGRa; extern const RawMode * const IMAGING_RAWMODE_BGRa;
extern const RawMode * const IMAGING_RAWMODE_B_16N;
extern const RawMode * const IMAGING_RAWMODE_C; extern const RawMode * const IMAGING_RAWMODE_C;
extern const RawMode * const IMAGING_RAWMODE_CMYK_I; extern const RawMode * const IMAGING_RAWMODE_CMYK_I;
extern const RawMode * const IMAGING_RAWMODE_CMYK_L; extern const RawMode * const IMAGING_RAWMODE_CMYK_L;
@ -92,6 +94,7 @@ extern const RawMode * const IMAGING_RAWMODE_Cr;
extern const RawMode * const IMAGING_RAWMODE_F_32F; extern const RawMode * const IMAGING_RAWMODE_F_32F;
extern const RawMode * const IMAGING_RAWMODE_F_32NF; extern const RawMode * const IMAGING_RAWMODE_F_32NF;
extern const RawMode * const IMAGING_RAWMODE_G; extern const RawMode * const IMAGING_RAWMODE_G;
extern const RawMode * const IMAGING_RAWMODE_G_16N;
extern const RawMode * const IMAGING_RAWMODE_H; extern const RawMode * const IMAGING_RAWMODE_H;
extern const RawMode * const IMAGING_RAWMODE_I_32NS; extern const RawMode * const IMAGING_RAWMODE_I_32NS;
extern const RawMode * const IMAGING_RAWMODE_I_32S; extern const RawMode * const IMAGING_RAWMODE_I_32S;
@ -108,6 +111,7 @@ extern const RawMode * const IMAGING_RAWMODE_R;
extern const RawMode * const IMAGING_RAWMODE_RGBA_L; extern const RawMode * const IMAGING_RAWMODE_RGBA_L;
extern const RawMode * const IMAGING_RAWMODE_RGBX_L; extern const RawMode * const IMAGING_RAWMODE_RGBX_L;
extern const RawMode * const IMAGING_RAWMODE_RGB_L; extern const RawMode * const IMAGING_RAWMODE_RGB_L;
extern const RawMode * const IMAGING_RAWMODE_R_16N;
extern const RawMode * const IMAGING_RAWMODE_S; extern const RawMode * const IMAGING_RAWMODE_S;
extern const RawMode * const IMAGING_RAWMODE_V; extern const RawMode * const IMAGING_RAWMODE_V;
extern const RawMode * const IMAGING_RAWMODE_X; extern const RawMode * const IMAGING_RAWMODE_X;

View File

@ -246,14 +246,10 @@ _pickUnpackers(
// We'll pick appropriate set of unpackers depending on planar_configuration // We'll pick appropriate set of unpackers depending on planar_configuration
// It does not matter if data is RGB(A), CMYK or LUV really, // It does not matter if data is RGB(A), CMYK or LUV really,
// we just copy it plane by plane // we just copy it plane by plane
unpackers[0] = unpackers[0] = ImagingFindUnpacker(IMAGING_MODE_RGBA, bits_per_sample == 16 ? IMAGING_RAWMODE_R_16N : IMAGING_RAWMODE_R, NULL);
ImagingFindUnpacker("RGBA", bits_per_sample == 16 ? "R;16N" : "R", NULL); unpackers[1] = ImagingFindUnpacker(IMAGING_MODE_RGBA, bits_per_sample == 16 ? IMAGING_RAWMODE_G_16N : IMAGING_RAWMODE_G, NULL);
unpackers[1] = unpackers[2] = ImagingFindUnpacker(IMAGING_MODE_RGBA, bits_per_sample == 16 ? IMAGING_RAWMODE_B_16N : IMAGING_RAWMODE_B, NULL);
ImagingFindUnpacker("RGBA", bits_per_sample == 16 ? "G;16N" : "G", NULL); unpackers[3] = ImagingFindUnpacker(IMAGING_MODE_RGBA, bits_per_sample == 16 ? IMAGING_RAWMODE_A_16N : IMAGING_RAWMODE_A, NULL);
unpackers[2] =
ImagingFindUnpacker("RGBA", bits_per_sample == 16 ? "B;16N" : "B", NULL);
unpackers[3] =
ImagingFindUnpacker("RGBA", bits_per_sample == 16 ? "A;16N" : "A", NULL);
return im->bands; return im->bands;
} else { } else {
@ -642,7 +638,7 @@ ImagingLibTiffDecode(
); );
TRACE( TRACE(
("Image: mode %s, type %d, bands: %d, xsize %d, ysize %d \n", ("Image: mode %s, type %d, bands: %d, xsize %d, ysize %d \n",
im->mode, im->mode->name,
im->type, im->type,
im->bands, im->bands,
im->xsize, im->xsize,
@ -753,7 +749,7 @@ ImagingLibTiffDecode(
if (!state->errcode) { if (!state->errcode) {
// Check if raw mode was RGBa and it was stored on separate planes // Check if raw mode was RGBa and it was stored on separate planes
// so we have to convert it to RGBA // so we have to convert it to RGBA
if (planes > 3 && strcmp(im->mode, "RGBA") == 0) { if (planes > 3 && im->mode == IMAGING_MODE_RGBA) {
uint16_t extrasamples; uint16_t extrasamples;
uint16_t *sampleinfo; uint16_t *sampleinfo;
ImagingShuffler shuffle; ImagingShuffler shuffle;
@ -765,7 +761,7 @@ ImagingLibTiffDecode(
if (extrasamples >= 1 && (sampleinfo[0] == EXTRASAMPLE_UNSPECIFIED || if (extrasamples >= 1 && (sampleinfo[0] == EXTRASAMPLE_UNSPECIFIED ||
sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA)) { sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA)) {
shuffle = ImagingFindUnpacker("RGBA", "RGBa", NULL); shuffle = ImagingFindUnpacker(IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBa, NULL);
for (y = state->yoff; y < state->ysize; y++) { for (y = state->yoff; y < state->ysize; y++) {
UINT8 *ptr = (UINT8 *)im->image[y + state->yoff] + UINT8 *ptr = (UINT8 *)im->image[y + state->yoff] +
@ -976,7 +972,7 @@ ImagingLibTiffEncode(Imaging im, ImagingCodecState state, UINT8 *buffer, int byt
); );
TRACE( TRACE(
("Image: mode %s, type %d, bands: %d, xsize %d, ysize %d \n", ("Image: mode %s, type %d, bands: %d, xsize %d, ysize %d \n",
im->mode, im->mode->name,
im->type, im->type,
im->bands, im->bands,
im->xsize, im->xsize,