diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2022-03-26 14:32:17 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2022-03-26 15:45:00 +0000 |
commit | c7dce05437d572d6417702c07221b856c88c9d7d (patch) | |
tree | 64dceb7b676ea22915582bc52646974bc4175dc2 /content/handlers | |
parent | 60b12cd9fe2b543aca4359ff0ba3f27ad27ae6ce (diff) | |
download | netsurf-c7dce05437d572d6417702c07221b856c88c9d7d.tar.gz netsurf-c7dce05437d572d6417702c07221b856c88c9d7d.tar.bz2 |
Image: ICO: Abstract image decode into helper.
Diffstat (limited to 'content/handlers')
-rw-r--r-- | content/handlers/image/ico.c | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/content/handlers/image/ico.c b/content/handlers/image/ico.c index 6f3e67e8b..871da41a9 100644 --- a/content/handlers/image/ico.c +++ b/content/handlers/image/ico.c @@ -173,6 +173,23 @@ static bool nsico_convert(struct content *c) return true; } +static bool nsico__decode(struct bmp_image *ico) +{ + if (ico->decoded == false) { + NSLOG(netsurf, DEBUG, "Decoding ICO %p", ico); + if (bmp_decode(ico) != BMP_OK) { + return false; + } + + bitmap_format_to_client(ico->bitmap, &(bitmap_fmt_t) { + .layout = BITMAP_LAYOUT_R8G8B8A8, + }); + guit->bitmap->modified(ico->bitmap); + + } + + return true; +} static bool nsico_redraw(struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx) @@ -189,17 +206,8 @@ static bool nsico_redraw(struct content *c, struct content_redraw_data *data, } /* ensure its decided */ - if (bmp->decoded == false) { - if (bmp_decode(bmp) != BMP_OK) { - return false; - } else { - NSLOG(netsurf, INFO, "Decoding bitmap"); - bitmap_format_to_client(bmp->bitmap, &(bitmap_fmt_t) { - .layout = BITMAP_LAYOUT_R8G8B8A8, - }); - guit->bitmap->modified(bmp->bitmap); - } - + if (!nsico__decode(bmp)) { + return false; } return image_bitmap_plot(bmp->bitmap, data, clip, ctx); @@ -263,15 +271,8 @@ static void *nsico_get_internal(const struct content *c, void *context) return NULL; } - if (bmp->decoded == false) { - if (bmp_decode(bmp) != BMP_OK) { - return NULL; - } else { - bitmap_format_to_client(bmp->bitmap, &(bitmap_fmt_t) { - .layout = BITMAP_LAYOUT_R8G8B8A8, - }); - guit->bitmap->modified(bmp->bitmap); - } + if (!nsico__decode(bmp)) { + return NULL; } return bmp->bitmap; @@ -298,15 +299,8 @@ static bool nsico_is_opaque(struct content *c) return false; } - if (bmp->decoded == false) { - if (bmp_decode(bmp) != BMP_OK) { - return false; - } - - bitmap_format_to_client(bmp->bitmap, &(bitmap_fmt_t) { - .layout = BITMAP_LAYOUT_R8G8B8A8, - }); - guit->bitmap->modified(bmp->bitmap); + if (!nsico__decode(bmp)) { + return false; } return guit->bitmap->get_opaque(bmp->bitmap); |