diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2022-03-27 10:17:48 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2022-03-27 10:17:48 +0100 |
commit | fba7a349c073287418587b8892dfb9bd8b29490a (patch) | |
tree | 8d3e605a87e09420c60ea88177906f134fc7f7d1 /content/handlers/image | |
parent | 694a3b4c989d9628a3dd5b7e1f3723d15f432891 (diff) | |
download | netsurf-fba7a349c073287418587b8892dfb9bd8b29490a.tar.gz netsurf-fba7a349c073287418587b8892dfb9bd8b29490a.tar.bz2 |
Image: Sprite: Avoid multiple bitmap format conversions.
Diffstat (limited to 'content/handlers/image')
-rw-r--r-- | content/handlers/image/nssprite.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/content/handlers/image/nssprite.c b/content/handlers/image/nssprite.c index c9284f4dd..a98c48aa2 100644 --- a/content/handlers/image/nssprite.c +++ b/content/handlers/image/nssprite.c @@ -23,6 +23,8 @@ #include <stdbool.h> #include <stdlib.h> +#include <string.h> + #include <librosprite.h> #include "utils/utils.h" @@ -129,19 +131,7 @@ static bool nssprite_convert(struct content *c) } unsigned char *spritebuf = (unsigned char *)sprite->image; - /* reverse byte order of each word */ - for (uint32_t y = 0; y < sprite->height; y++) { - for (uint32_t x = 0; x < sprite->width; x++) { - int offset = 4 * (y * sprite->width + x); - - *imagebuf = (spritebuf[offset] << 24) | - (spritebuf[offset + 1] << 16) | - (spritebuf[offset + 2] << 8) | - (spritebuf[offset + 3]); - - imagebuf++; - } - } + memcpy(imagebuf, spritebuf, sprite->width * sprite->height * 4); c->width = sprite->width; c->height = sprite->height; @@ -156,7 +146,7 @@ static bool nssprite_convert(struct content *c) } bitmap_format_to_client(nssprite->bitmap, &(bitmap_fmt_t) { - .layout = BITMAP_LAYOUT_R8G8B8A8, + .layout = BITMAP_LAYOUT_A8B8G8R8, }); guit->bitmap->modified(nssprite->bitmap); |