diff options
Diffstat (limited to 'content')
-rw-r--r-- | content/fs_backing_store.c | 5 | ||||
-rw-r--r-- | content/handlers/image/jpeg.c | 55 | ||||
-rw-r--r-- | content/handlers/image/rsvg.c | 14 |
3 files changed, 56 insertions, 18 deletions
diff --git a/content/fs_backing_store.c b/content/fs_backing_store.c index 1b59ea150..3736cc551 100644 --- a/content/fs_backing_store.c +++ b/content/fs_backing_store.c @@ -1565,6 +1565,7 @@ initialise(const struct llcache_store_parameters *parameters) ret = build_entrymap(newstate); if (ret != NSERROR_OK) { /* that obviously went well */ + free(newstate->entries); free(newstate->path); free(newstate); return ret; @@ -1573,6 +1574,8 @@ initialise(const struct llcache_store_parameters *parameters) ret = read_blocks(newstate); if (ret != NSERROR_OK) { /* oh dear */ + free(newstate->addrmap); + free(newstate->entries); free(newstate->path); free(newstate); return ret; @@ -1640,6 +1643,8 @@ finalise(void) 0); } + free(storestate->addrmap); + free(storestate->entries); free(storestate->path); free(storestate); storestate = NULL; diff --git a/content/handlers/image/jpeg.c b/content/handlers/image/jpeg.c index 44b1c5271..123a0bf70 100644 --- a/content/handlers/image/jpeg.c +++ b/content/handlers/image/jpeg.c @@ -214,7 +214,12 @@ jpeg_cache_convert(struct content *c) jpeg_read_header(&cinfo, TRUE); /* set output processing parameters */ - cinfo.out_color_space = JCS_RGB; + if (cinfo.jpeg_color_space == JCS_CMYK || + cinfo.jpeg_color_space == JCS_YCCK) { + cinfo.out_color_space = JCS_CMYK; + } else { + cinfo.out_color_space = JCS_RGB; + } cinfo.dct_method = JDCT_ISLOW; /* commence the decompression, output parameters now valid */ @@ -248,22 +253,42 @@ jpeg_cache_convert(struct content *c) rowstride * cinfo.output_scanline); jpeg_read_scanlines(&cinfo, scanlines, 1); + if (cinfo.out_color_space == JCS_CMYK) { + int i; + for (i = width - 1; 0 <= i; i--) { + /* Trivial inverse CMYK -> RGBA */ + const int c = scanlines[0][i * 4 + 0]; + const int m = scanlines[0][i * 4 + 1]; + const int y = scanlines[0][i * 4 + 2]; + const int k = scanlines[0][i * 4 + 3]; + + const int ck = c * k; + const int mk = m * k; + const int yk = y * k; + +#define DIV255(x) ((x) + 1 + ((x) >> 8)) >> 8 + scanlines[0][i * 4 + 0] = DIV255(ck); + scanlines[0][i * 4 + 1] = DIV255(mk); + scanlines[0][i * 4 + 2] = DIV255(yk); + scanlines[0][i * 4 + 3] = 0xff; +#undef DIV255 + } + } else { #if RGB_RED != 0 || RGB_GREEN != 1 || RGB_BLUE != 2 || RGB_PIXELSIZE != 4 -{ - /* Missmatch between configured libjpeg pixel format and - * NetSurf pixel format. Convert to RGBA */ - int i; - for (i = width - 1; 0 <= i; i--) { - int r = scanlines[0][i * RGB_PIXELSIZE + RGB_RED]; - int g = scanlines[0][i * RGB_PIXELSIZE + RGB_GREEN]; - int b = scanlines[0][i * RGB_PIXELSIZE + RGB_BLUE]; - scanlines[0][i * 4 + 0] = r; - scanlines[0][i * 4 + 1] = g; - scanlines[0][i * 4 + 2] = b; - scanlines[0][i * 4 + 3] = 0xff; - } -} + /* Missmatch between configured libjpeg pixel format and + * NetSurf pixel format. Convert to RGBA */ + int i; + for (i = width - 1; 0 <= i; i--) { + int r = scanlines[0][i * RGB_PIXELSIZE + RGB_RED]; + int g = scanlines[0][i * RGB_PIXELSIZE + RGB_GREEN]; + int b = scanlines[0][i * RGB_PIXELSIZE + RGB_BLUE]; + scanlines[0][i * 4 + 0] = r; + scanlines[0][i * 4 + 1] = g; + scanlines[0][i * 4 + 2] = b; + scanlines[0][i * 4 + 3] = 0xff; + } #endif + } } while (cinfo.output_scanline != cinfo.output_height); guit->bitmap->modified(bitmap); diff --git a/content/handlers/image/rsvg.c b/content/handlers/image/rsvg.c index ca2d81eeb..2ba1b49f5 100644 --- a/content/handlers/image/rsvg.c +++ b/content/handlers/image/rsvg.c @@ -39,6 +39,8 @@ #include <librsvg/rsvg-cairo.h> #endif +#include <nsutils/endian.h> + #include "utils/log.h" #include "utils/utils.h" #include "utils/messages.h" @@ -139,15 +141,21 @@ static inline void rsvg_argb_to_abgr(uint8_t *pixels, int width, int height, size_t rowstride) { uint8_t *p = pixels; + int boff = 0, roff = 2; + + if (endian_host_is_le() == false) { + boff = 1; + roff = 3; + } for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { /* Swap R and B */ - const uint8_t r = p[x+3]; + const uint8_t r = p[4*x+roff]; - p[x+3] = p[x]; + p[4*x+roff] = p[4*x+boff]; - p[x] = r; + p[4*x+boff] = r; } p += rowstride; |