From b0da0e5067137b5b472647c4259727b3817b2c6e Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 16 Oct 2010 13:50:35 +0000 Subject: Fix WebP images for little-endian processors, and enable for gtk build. Direct links work, images embedded in web pages are not showing up - test page at http://www.unsatisfactorysoftware.co.uk/netsurf/webptest/ svn path=/trunk/netsurf/; revision=10886 --- image/webp.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'image') diff --git a/image/webp.c b/image/webp.c index 7df6ccf35..3da1af7a7 100644 --- a/image/webp.c +++ b/image/webp.c @@ -48,6 +48,8 @@ bool webp_convert(struct content *c) unsigned long size; uint8 *Y = NULL, *U = NULL, *V = NULL; uint32 width = 0, height = 0; + uint32 x = 0, y = 0, offset = 0; + uint8 r, g, b, a; char title[100]; WebPResult res = webp_success; @@ -81,8 +83,22 @@ bool webp_convert(struct content *c) if(Y) free(Y); - /* I think we may need to reverse the byte order here, as it is fixed - * to RGBA on both big- and little-endian platforms. */ + /* Data is RGBA on both big- and little-endian platforms, + * so reverse the byte order. */ + + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + offset = 4 * (y * width + x); + r = imagebuf[offset+3]; + g = imagebuf[offset+2]; + b = imagebuf[offset+1]; + a = imagebuf[offset]; + imagebuf[offset] = r; + imagebuf[offset+1] = g; + imagebuf[offset+2] = b; + imagebuf[offset+3] = a; + } + } c->width = width; c->height = height; -- cgit v1.2.3