static
i_img *
-read_one_icon(ico_reader_t *file, int index, int masked) {
+read_one_icon(ico_reader_t *file, int index, int masked, int alpha_masked) {
ico_image_t *image;
int error;
i_img *result;
return NULL;
}
- if (masked) {
+ if (masked && (image->bit_count != 32 || alpha_masked)) {
/* check to make sure we should do the masking, if the mask has
nothing set we don't mask */
int pos;
i_color *line_buf;
i_color *outp;
ico_color_t *inp = image->image_data;
+ int channels = masked || image->bit_count == 32 ? 4 : 3;
- if (!i_int_check_image_file_limits(image->width, image->height, 4, 1)) {
+ if (!i_int_check_image_file_limits(image->width, image->height, channels, 1)) {
ico_image_release(image);
return NULL;
}
- result = i_img_8_new(image->width, image->height, 4);
+
+ result = i_img_8_new(image->width, image->height, channels);
if (!result) {
ico_image_release(image);
return NULL;
}
i_img *
-i_readico_single(io_glue *ig, int index, int masked) {
+i_readico_single(io_glue *ig, int index, int masked, int alpha_masked) {
ico_reader_t *file;
i_img *result;
int error;
/* the index is range checked by msicon.c - don't duplicate it here */
- result = read_one_icon(file, index, masked);
+ result = read_one_icon(file, index, masked, alpha_masked);
ico_reader_close(file);
return result;
}
i_img **
-i_readico_multi(io_glue *ig, int *count, int masked) {
+i_readico_multi(io_glue *ig, int *count, int masked, int alpha_masked) {
ico_reader_t *file;
int index;
int error;
*count = 0;
for (index = 0; index < ico_image_count(file); ++index) {
- i_img *im = read_one_icon(file, index, masked);
+ i_img *im = read_one_icon(file, index, masked, alpha_masked);
if (!im)
break;
static int
validate_image(i_img *im) {
- if (im->xsize > 255 || im->ysize > 255) {
+ if (im->xsize > 256 || im->ysize > 256) {
i_push_error(0, "image too large for ico file");
return 0;
}