OS/2 icons/pointers: refactor boolean flags

one icon flag and and mono flag instead of two color-icon/mono-icon
flags
This commit is contained in:
Rupert
2025-05-31 13:14:23 +02:00
committed by Rupert
parent 5cd33b22ca
commit 07d3bf6086
3 changed files with 12 additions and 11 deletions

View File

@@ -119,8 +119,8 @@ struct Bmpread {
int width;
int height;
enum BmpOrient orientation;
bool is_color_icon;
bool is_mono_icon;
bool is_icon;
bool icon_is_mono;
bool has_alpha; /* original BMP has alpha channel */
enum BmpUndefined undefined_mode;
bool we_allocated_buffer;

View File

@@ -277,7 +277,7 @@ static void s_read_one_line(BMPREAD_R rp, unsigned char *restrict line)
} else {
if (rp->ih->compression == BI_OS2_HUFFMAN) {
s_read_huffman_line(rp, line);
} else if (rp->is_mono_icon) {
} else if (rp->is_icon && rp->icon_is_mono) {
s_read_monoicon_line(rp, line, rp->lbl_y);
} else {
s_read_indexed_line(rp, line);
@@ -298,7 +298,7 @@ static void s_read_one_line(BMPREAD_R rp, unsigned char *restrict line)
s_read_rgb_line(rp, line);
}
if (rp->is_color_icon || rp->is_mono_icon) {
if (rp->is_icon) {
apply_icon_alpha(rp, rp->lbl_y, line);
}

View File

@@ -141,10 +141,11 @@ API BMPRESULT bmpread_load_info(BMPHANDLE h)
goto abort;
}
rp->is_icon = true;
if (type == BMPFILE_CI || type == BMPFILE_CP)
rp->is_color_icon = true;
rp->icon_is_mono = false;
else
rp->is_mono_icon = true;
rp->icon_is_mono = true;
}
/* otherwise we read the AND/XOR masks as a normal image */
@@ -184,7 +185,7 @@ API BMPRESULT bmpread_load_info(BMPHANDLE h)
/* negative height flips the image vertically */
if (rp->ih->height < 0) {
if (rp->is_color_icon || rp->is_mono_icon) {
if (rp->is_icon) {
logerr(rp->c.log, "Top-down orientation incompatible with icons/pointers");
rp->lasterr = BMP_ERR_HEADER;
goto abort;
@@ -200,7 +201,7 @@ API BMPRESULT bmpread_load_info(BMPHANDLE h)
rp->height = rp->ih->height;
}
if (rp->is_mono_icon)
if (rp->is_icon && rp->icon_is_mono)
rp->height /= 2;
if (rp->ih->compression == BI_RLE4 ||
@@ -248,7 +249,7 @@ API BMPRESULT bmpread_load_info(BMPHANDLE h)
if (rp->rle) {
rp->result_channels = (rp->undefined_mode == BMP_UNDEFINED_TO_ALPHA) ? 4 : 3;
}
if (rp->is_color_icon || rp->is_mono_icon)
if (rp->is_icon)
rp->result_channels = 4;
if (!br_set_resultbits(rp))
@@ -532,7 +533,7 @@ BMPRESULT br_set_number_format(BMPREAD_R rp, enum BmpFormat format)
rp->lasterr = BMP_ERR_FORMAT;
return BMP_RESULT_ERROR;
}
if (rp->is_color_icon || rp->is_mono_icon) {
if (rp->is_icon) {
logerr(rp->c.log, "Cannot load icons/pointers as float or s2.13");
rp->lasterr = BMP_ERR_FORMAT;
return BMP_RESULT_ERROR;
@@ -795,7 +796,7 @@ static bool s_is_bmptype_supported(BMPREAD_R rp)
return false;
}
if (rp->is_color_icon || rp->is_mono_icon) {
if (rp->is_icon) {
if (rp->ih->compression != BI_RGB) {
logerr(rp->c.log, "Unsupported compression %s for icon/pointer",
s_compression_name(rp->ih->compression));