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
This commit is contained in:
Chris Young 2010-10-16 13:50:35 +00:00
parent 43029944ae
commit b0da0e5067
4 changed files with 29 additions and 3 deletions

View File

@ -442,6 +442,7 @@ ifeq ($(TARGET),gtk)
NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
NETSURF_FEATURE_WEBP_CFLAGS := -DWITH_WEBP
# add a line similar to below for each optional pkg-configed lib here
$(eval $(call pkg_config_find_and_add,RSVG,librsvg-2.0,SVG))
@ -451,6 +452,9 @@ ifeq ($(TARGET),gtk)
$(eval $(call pkg_config_find_and_add,GIF,libnsgif,GIF))
$(eval $(call pkg_config_find_and_add,PNG,libpng,PNG ))
# no pkg-config for this library
$(eval $(call feature_enabled,WEBP,-DWITH_WEBP,-lwebp -lvpx,WebP (libwebp)))
GTKCFLAGS := -std=c99 -Dgtk -Dnsgtk \
-DGTK_DISABLE_DEPRECATED \
-D_BSD_SOURCE \

View File

@ -51,7 +51,7 @@ NETSURF_USE_PNG := YES
# Enable NetSurf's use of libmng for displaying MNGs, JNGs and PNGs
# Valid options: YES, NO (at least one of PNG/MNG highly recommended)
NETSURF_USE_MNG := YES
NETSURF_USE_MNG := NO
# Enable NetSurf's use of libwebp/libvpx for displaying WebPs
# Valid options: YES, NO
@ -146,6 +146,10 @@ ifeq ($(TARGET),gtk)
# Valid options: YES, NO, AUTO
NETSURF_USE_ROSPRITE := AUTO
# Enable NetSurf's use of libwebp/libvpx for displaying WebPs
# Valid options: YES, NO
NETSURF_USE_WEBP := YES
# Configuration overrides for Mac OS X
ifeq ($(HOST),macosx)
NETSURF_USE_LIBICONV_PLUG := NO

View File

@ -64,6 +64,8 @@ void gtk_fetch_filetype_init(const char *mimefile)
hash_add(mime_hash, "gif", "image/gif");
hash_add(mime_hash, "png", "image/png");
hash_add(mime_hash, "jng", "image/jng");
hash_add(mime_hash, "mng", "image/mng");
hash_add(mime_hash, "webp", "image/webp");
hash_add(mime_hash, "spr", "image/x-riscos-sprite");
if (fh == NULL) {

View File

@ -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;