summaryrefslogtreecommitdiff
path: root/xps/xps_png.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-04-03 15:17:00 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-04-03 16:01:34 +0200
commit8975aec496710bb9e35a4a1cb635ee0d4eaa60cc (patch)
tree02e02a337491fd66be2c60b0c8aa2b969ca47e69 /xps/xps_png.c
parent6af0abc477539365a19a4797babfd567da4d375f (diff)
downloadmupdf-8975aec496710bb9e35a4a1cb635ee0d4eaa60cc.tar.xz
xps: Use fz_pixmap directly instead of wrapping it in xps_image.
Diffstat (limited to 'xps/xps_png.c')
-rw-r--r--xps/xps_png.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/xps/xps_png.c b/xps/xps_png.c
index f59be56d..829bde90 100644
--- a/xps/xps_png.c
+++ b/xps/xps_png.c
@@ -489,6 +489,9 @@ png_expand_palette(struct info *info, fz_pixmap *src)
unsigned char *dp = dst->samples;
int x, y;
+ dst->xres = src->xres;
+ dst->yres = src->yres;
+
for (y = 0; y < info->height; y++)
{
for (x = 0; x < info->width; x++)
@@ -531,11 +534,10 @@ png_mask_transparency(struct info *info, fz_pixmap *dst)
}
int
-xps_decode_png(xps_image **imagep, xps_context *ctx, byte *p, int total)
+xps_decode_png(fz_pixmap **imagep, byte *p, int total)
{
- fz_pixmap *pixmap;
+ fz_pixmap *image;
fz_colorspace *colorspace;
- xps_image *image;
struct info png;
int code;
int stride;
@@ -551,30 +553,22 @@ xps_decode_png(xps_image **imagep, xps_context *ctx, byte *p, int total)
stride = (png.width * png.n * png.depth + 7) / 8;
- pixmap = fz_newpixmap(colorspace, 0, 0, png.width, png.height);
- fz_unpacktile(pixmap, png.samples, png.n, png.depth, stride, png.indexed);
+ image = fz_newpixmap(colorspace, 0, 0, png.width, png.height);
+ image->xres = png.xres;
+ image->yres = png.yres;
+
+ fz_unpacktile(image, png.samples, png.n, png.depth, stride, png.indexed);
if (png.indexed)
- {
- pixmap = png_expand_palette(&png, pixmap);
- }
+ image = png_expand_palette(&png, image);
else if (png.transparency)
- {
- png_mask_transparency(&png, pixmap);
- }
+ png_mask_transparency(&png, image);
if (png.transparency || png.n == 2 || png.n == 4)
- {
- fz_premultiplypixmap(pixmap);
- }
+ fz_premultiplypixmap(image);
fz_free(png.samples);
- image = fz_malloc(sizeof(xps_image));
- image->pixmap = pixmap;
- image->xres = png.xres;
- image->yres = png.yres;
-
*imagep = image;
return fz_okay;
}