summaryrefslogtreecommitdiff
path: root/image/webp.c
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2010-10-16 13:50:35 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2010-10-16 13:50:35 +0000
commitb0da0e5067137b5b472647c4259727b3817b2c6e (patch)
tree67cd5f64a8217c98f62d3cf841c4cba045605c7d /image/webp.c
parent43029944aea1d3655c675f86d0874d620f65b885 (diff)
downloadnetsurf-b0da0e5067137b5b472647c4259727b3817b2c6e.tar.gz
netsurf-b0da0e5067137b5b472647c4259727b3817b2c6e.tar.bz2
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
Diffstat (limited to 'image/webp.c')
-rw-r--r--image/webp.c20
1 files changed, 18 insertions, 2 deletions
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;