use mode structs in Jpeg2KEncode.c

This commit is contained in:
Yay295 2024-04-21 19:52:05 -05:00
parent 56e1b3c8ef
commit 5836c00d8d

View File

@ -305,28 +305,28 @@ j2k_encode_entry(Imaging im, ImagingCodecState state) {
#endif
/* Setup an opj_image */
if (strcmp(im->mode, "L") == 0) {
if (im->mode == IMAGING_MODE_L) {
components = 1;
color_space = OPJ_CLRSPC_GRAY;
pack = j2k_pack_l;
} else if (strcmp(im->mode, "I;16") == 0 || strcmp(im->mode, "I;16B") == 0) {
} else if (im->mode == IMAGING_MODE_I_16 || im->mode == IMAGING_MODE_I_16B) {
components = 1;
color_space = OPJ_CLRSPC_GRAY;
pack = j2k_pack_i16;
prec = 16;
} else if (strcmp(im->mode, "LA") == 0) {
} else if (im->mode == IMAGING_MODE_LA) {
components = 2;
color_space = OPJ_CLRSPC_GRAY;
pack = j2k_pack_la;
} else if (strcmp(im->mode, "RGB") == 0) {
} else if (im->mode == IMAGING_MODE_RGB) {
components = 3;
color_space = OPJ_CLRSPC_SRGB;
pack = j2k_pack_rgb;
} else if (strcmp(im->mode, "YCbCr") == 0) {
} else if (im->mode == IMAGING_MODE_YCbCr) {
components = 3;
color_space = OPJ_CLRSPC_SYCC;
pack = j2k_pack_rgb;
} else if (strcmp(im->mode, "RGBA") == 0) {
} else if (im->mode == IMAGING_MODE_RGBA) {
components = 4;
color_space = OPJ_CLRSPC_SRGB;
pack = j2k_pack_rgba;
@ -490,9 +490,9 @@ j2k_encode_entry(Imaging im, ImagingCodecState state) {
goto quick_exit;
}
if (strcmp(im->mode, "RGBA") == 0) {
if (im->mode == IMAGING_MODE_RGBA) {
image->comps[3].alpha = 1;
} else if (strcmp(im->mode, "LA") == 0) {
} else if (im->mode == IMAGING_MODE_LA) {
image->comps[1].alpha = 1;
}