diff options
author | Tor Andersson <tor@ghostscript.com> | 2004-10-27 06:57:02 +0200 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2004-10-27 06:57:02 +0200 |
commit | 3506472774c72aae2751ddbd54e4c62d82156410 (patch) | |
tree | 656b48ebd0a8a1378f13b6ba68ca46d90f2ed6ac /render/pixmap.c | |
parent | 434ccadcfc04b02c9ff24166358e859a410288c8 (diff) | |
download | mupdf-3506472774c72aae2751ddbd54e4c62d82156410.tar.xz |
clean up image rendering
Diffstat (limited to 'render/pixmap.c')
-rw-r--r-- | render/pixmap.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/render/pixmap.c b/render/pixmap.c index 07eea36e..acb1d1d2 100644 --- a/render/pixmap.c +++ b/render/pixmap.c @@ -61,7 +61,7 @@ fz_convertpixmap(fz_pixmap **dstp, fz_pixmap *src, fz_colorspace *srcs, fz_color { for (x = 0; x < src->w; x++) { - *s++ = *d++; + *d++ = *s++; for (k = 0; k < src->n - 1; k++) srcv[k] = *s++ / 255.0; @@ -69,7 +69,7 @@ fz_convertpixmap(fz_pixmap **dstp, fz_pixmap *src, fz_colorspace *srcs, fz_color fz_convertcolor(srcs, srcv, dsts, dstv); for (k = 0; k < dst->n - 1; k++) - *d++ = dstv[k] * 255 + 0.5; + *d++ = dstv[k] * 255; } } @@ -131,6 +131,21 @@ fz_blendmask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk) } void +fz_gammapixmap(fz_pixmap *pix, float gamma) +{ + int i; + unsigned char table[255]; + for (i = 0; i < 256; i++) + table[i] = CLAMP(pow(i / 255.0, gamma) * 255.0, 0, 255); + int n = pix->w * pix->h * pix->n; + unsigned char *p = pix->samples; + while (n--) + { + *p = table[*p]; p++; + } +} + +void fz_debugpixmap(fz_pixmap *pix) { if (pix->n == 4) |