diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-04-08 22:25:39 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-04-08 22:25:39 +0200 |
commit | 42e89d924112d0aea66245f46b8a25ab120c44da (patch) | |
tree | 094892cdaf9f1087599aa9b6bd53b052015d54a5 | |
parent | ae039a6b71fb9afddd29cf289e0f9a2be23803c5 (diff) | |
download | mupdf-42e89d924112d0aea66245f46b8a25ab120c44da.tar.xz |
Simplify arguments to fz_new_pixmap.
-rw-r--r-- | apps/pdfextract.c | 2 | ||||
-rw-r--r-- | draw/draw_device.c | 4 | ||||
-rw-r--r-- | draw/draw_scale.c | 6 | ||||
-rw-r--r-- | fitz/filt_jpxd.c | 4 | ||||
-rw-r--r-- | fitz/fitz.h | 4 | ||||
-rw-r--r-- | fitz/res_font.c | 11 | ||||
-rw-r--r-- | fitz/res_halftone.c | 2 | ||||
-rw-r--r-- | fitz/res_pixmap.c | 18 | ||||
-rw-r--r-- | pdf/pdf_colorspace.c | 2 | ||||
-rw-r--r-- | pdf/pdf_image.c | 2 | ||||
-rw-r--r-- | xps/xps_jpeg.c | 2 | ||||
-rw-r--r-- | xps/xps_png.c | 4 | ||||
-rw-r--r-- | xps/xps_tiff.c | 4 |
13 files changed, 38 insertions, 27 deletions
diff --git a/apps/pdfextract.c b/apps/pdfextract.c index 45185cee..7e6e4ace 100644 --- a/apps/pdfextract.c +++ b/apps/pdfextract.c @@ -54,7 +54,7 @@ static void saveimage(int num) if (dorgb && img->colorspace && img->colorspace != fz_device_rgb) { fz_pixmap *temp; - temp = fz_new_pixmap(fz_device_rgb, img->x, img->y, img->w, img->h); + temp = fz_new_pixmap_with_rect(fz_device_rgb, fz_bound_pixmap(img)); fz_convert_pixmap(img, temp); fz_drop_pixmap(img); img = temp; diff --git a/draw/draw_device.c b/draw/draw_device.c index fe93183d..1e011b30 100644 --- a/draw/draw_device.c +++ b/draw/draw_device.c @@ -593,7 +593,7 @@ fz_draw_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha) if (image->colorspace != model && !after) { - converted = fz_new_pixmap(model, image->x, image->y, image->w, image->h); + converted = fz_new_pixmap_with_rect(model, fz_bound_pixmap(image)); fz_convert_pixmap(image, converted); image = converted; } @@ -624,7 +624,7 @@ fz_draw_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha) } else { - converted = fz_new_pixmap(model, image->x, image->y, image->w, image->h); + converted = fz_new_pixmap_with_rect(model, fz_bound_pixmap(image)); fz_convert_pixmap(image, converted); image = converted; } diff --git a/draw/draw_scale.c b/draw/draw_scale.c index f66974d3..a6fb2817 100644 --- a/draw/draw_scale.c +++ b/draw/draw_scale.c @@ -1090,9 +1090,9 @@ fz_scale_pixmap(fz_pixmap *src, float x, float y, float w, float h) assert(contrib_cols == NULL || contrib_cols->count == dst_w_int); assert(contrib_rows == NULL || contrib_rows->count == dst_h_int); - output = fz_new_pixmap(src->colorspace, dst_x_int, dst_y_int, dst_w_int, dst_h_int); - if (output == NULL) - goto cleanup; + output = fz_new_pixmap(src->colorspace, dst_w_int, dst_h_int); + output->x = dst_x_int; + output->y = dst_y_int; /* Step 2: Apply the weights */ #ifdef SINGLE_PIXEL_SPECIALS diff --git a/fitz/filt_jpxd.c b/fitz/filt_jpxd.c index d43ee4c4..4fb8264d 100644 --- a/fitz/filt_jpxd.c +++ b/fitz/filt_jpxd.c @@ -108,7 +108,7 @@ fz_load_jpx_image(fz_pixmap **imgp, unsigned char *data, int size, fz_colorspace } } - img = fz_new_pixmap(colorspace, 0, 0, w, h); + img = fz_new_pixmap(colorspace, w, h); p = img->samples; for (y = 0; y < h; y++) @@ -133,7 +133,7 @@ fz_load_jpx_image(fz_pixmap **imgp, unsigned char *data, int size, fz_colorspace { if (n == 4) { - fz_pixmap *tmp = fz_new_pixmap(fz_device_rgb, 0, 0, w, h); + fz_pixmap *tmp = fz_new_pixmap(fz_device_rgb, w, h); fz_convert_pixmap(img, tmp); fz_drop_pixmap(img); img = tmp; diff --git a/fitz/fitz.h b/fitz/fitz.h index 0ae31631..111df17e 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -680,9 +680,9 @@ struct fz_pixmap_s int free_samples; }; -fz_pixmap *fz_new_pixmap_with_data(fz_colorspace *colorspace, int x, int y, int w, int h, unsigned char *samples); +fz_pixmap *fz_new_pixmap_with_data(fz_colorspace *colorspace, int w, int h, unsigned char *samples); fz_pixmap *fz_new_pixmap_with_rect(fz_colorspace *, fz_bbox bbox); -fz_pixmap *fz_new_pixmap(fz_colorspace *, int x, int y, int w, int h); +fz_pixmap *fz_new_pixmap(fz_colorspace *, int w, int h); fz_pixmap *fz_keep_pixmap(fz_pixmap *pix); void fz_drop_pixmap(fz_pixmap *pix); void fz_clear_pixmap(fz_pixmap *pix); diff --git a/fitz/res_font.c b/fitz/res_font.c index 6aca0c44..e2542f9b 100644 --- a/fitz/res_font.c +++ b/fitz/res_font.c @@ -267,7 +267,9 @@ fz_copy_ft_bitmap(int left, int top, FT_Bitmap *bitmap) fz_pixmap *pixmap; int y; - pixmap = fz_new_pixmap(NULL, left, top - bitmap->rows, bitmap->width, bitmap->rows); + pixmap = fz_new_pixmap(NULL, bitmap->width, bitmap->rows); + pixmap->x = left; + pixmap->y = top - bitmap->rows; if (bitmap->pixel_mode == FT_PIXEL_MODE_MONO) { @@ -517,7 +519,12 @@ fz_render_t3_glyph(fz_font *font, int gid, fz_matrix trm) fz_catch(error, "cannot draw type3 glyph"); fz_free_device(dev); - glyph = fz_new_pixmap(fz_device_gray, bbox.x0-1, bbox.y0-1, bbox.x1 - bbox.x0 + 1, bbox.y1 - bbox.y0 + 1); + bbox.x0--; + bbox.y0--; + bbox.x1++; + bbox.y1++; + + glyph = fz_new_pixmap_with_rect(fz_device_gray, bbox); fz_clear_pixmap(glyph); cache = fz_new_glyph_cache(); diff --git a/fitz/res_halftone.c b/fitz/res_halftone.c index 139be112..6a7a8f42 100644 --- a/fitz/res_halftone.c +++ b/fitz/res_halftone.c @@ -67,7 +67,7 @@ fz_halftone *fz_get_default_halftone(int num_comps) /* Only support 1 component for now */ assert(num_comps == 1); - ht->comp[0] = fz_new_pixmap_with_data(NULL, 0, 0, 16, 16, mono_ht); + ht->comp[0] = fz_new_pixmap_with_data(NULL, 16, 16, mono_ht); if (ht->comp[0] == NULL) { fz_drop_halftone(ht); diff --git a/fitz/res_pixmap.c b/fitz/res_pixmap.c index 7e689e07..c6410a80 100644 --- a/fitz/res_pixmap.c +++ b/fitz/res_pixmap.c @@ -1,14 +1,14 @@ #include "fitz.h" fz_pixmap * -fz_new_pixmap_with_data(fz_colorspace *colorspace, int x, int y, int w, int h, unsigned char *samples) +fz_new_pixmap_with_data(fz_colorspace *colorspace, int w, int h, unsigned char *samples) { fz_pixmap *pix; pix = fz_malloc(sizeof(fz_pixmap)); pix->refs = 1; - pix->x = x; - pix->y = y; + pix->x = 0; + pix->y = 0; pix->w = w; pix->h = h; pix->mask = NULL; @@ -39,15 +39,19 @@ fz_new_pixmap_with_data(fz_colorspace *colorspace, int x, int y, int w, int h, u } fz_pixmap * -fz_new_pixmap(fz_colorspace *colorspace, int x, int y, int w, int h) +fz_new_pixmap(fz_colorspace *colorspace, int w, int h) { - return fz_new_pixmap_with_data(colorspace, x, y, w, h, NULL); + return fz_new_pixmap_with_data(colorspace, w, h, NULL); } fz_pixmap * fz_new_pixmap_with_rect(fz_colorspace *colorspace, fz_bbox r) { - return fz_new_pixmap(colorspace, r.x0, r.y0, r.x1 - r.x0, r.y1 - r.y0); + fz_pixmap *pixmap; + pixmap = fz_new_pixmap(colorspace, r.x1 - r.x0, r.y1 - r.y0); + pixmap->x = r.x0; + pixmap->y = r.y0; + return pixmap; } fz_pixmap * @@ -138,7 +142,7 @@ fz_alpha_from_gray(fz_pixmap *gray, int luminosity) assert(gray->n == 2); - alpha = fz_new_pixmap(NULL, gray->x, gray->y, gray->w, gray->h); + alpha = fz_new_pixmap_with_rect(NULL, fz_bound_pixmap(gray)); dp = alpha->samples; sp = gray->samples; if (!luminosity) diff --git a/pdf/pdf_colorspace.c b/pdf/pdf_colorspace.c index a7b04166..b7ea51a3 100644 --- a/pdf/pdf_colorspace.c +++ b/pdf/pdf_colorspace.c @@ -183,7 +183,7 @@ pdf_expand_indexed_pixmap(fz_pixmap *src) lookup = idx->lookup; n = idx->base->n; - dst = fz_new_pixmap(idx->base, src->x, src->y, src->w, src->h); + dst = fz_new_pixmap_with_rect(idx->base, fz_bound_pixmap(src)); s = src->samples; d = dst->samples; diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c index fbd88f01..14d711cd 100644 --- a/pdf/pdf_image.c +++ b/pdf/pdf_image.c @@ -221,7 +221,7 @@ pdf_load_image_imp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, /* Unpack samples into pixmap */ - tile = fz_new_pixmap(colorspace, 0, 0, w, h); + tile = fz_new_pixmap(colorspace, w, h); scale = 1; if (!indexed) diff --git a/xps/xps_jpeg.c b/xps/xps_jpeg.c index 8cf00c20..9a7462ef 100644 --- a/xps/xps_jpeg.c +++ b/xps/xps_jpeg.c @@ -94,7 +94,7 @@ xps_decode_jpeg(fz_pixmap **imagep, byte *rbuf, int rlen) else return fz_throw("bad number of components in jpeg: %d", cinfo.output_components); - image = fz_new_pixmap(colorspace, 0, 0, cinfo.output_width, cinfo.output_height); + image = fz_new_pixmap(colorspace, cinfo.output_width, cinfo.output_height); if (cinfo.density_unit == 1) { diff --git a/xps/xps_png.c b/xps/xps_png.c index a86aa54f..c1ed9683 100644 --- a/xps/xps_png.c +++ b/xps/xps_png.c @@ -482,7 +482,7 @@ png_read_image(struct info *info, unsigned char *p, int total) static fz_pixmap * png_expand_palette(struct info *info, fz_pixmap *src) { - fz_pixmap *dst = fz_new_pixmap(fz_device_rgb, 0, 0, src->w, src->h); + fz_pixmap *dst = fz_new_pixmap(fz_device_rgb, src->w, src->h); unsigned char *sp = src->samples; unsigned char *dp = dst->samples; int x, y; @@ -551,7 +551,7 @@ xps_decode_png(fz_pixmap **imagep, byte *p, int total) stride = (png.width * png.n * png.depth + 7) / 8; - image = fz_new_pixmap(colorspace, 0, 0, png.width, png.height); + image = fz_new_pixmap(colorspace, png.width, png.height); image->xres = png.xres; image->yres = png.yres; diff --git a/xps/xps_tiff.c b/xps/xps_tiff.c index d946434f..15406a05 100644 --- a/xps/xps_tiff.c +++ b/xps/xps_tiff.c @@ -822,7 +822,7 @@ xps_decode_tiff(fz_pixmap **imagep, byte *buf, int len) /* Expand into fz_pixmap struct */ - image = fz_new_pixmap(tiff.colorspace, 0, 0, tiff.imagewidth, tiff.imagelength); + image = fz_new_pixmap(tiff.colorspace, tiff.imagewidth, tiff.imagelength); image->xres = tiff.xresolution; image->yres = tiff.yresolution; @@ -834,7 +834,7 @@ xps_decode_tiff(fz_pixmap **imagep, byte *buf, int len) /* CMYK is a subtractive colorspace, we want additive for premul alpha */ if (image->n == 5) { - fz_pixmap *rgb = fz_new_pixmap(fz_device_rgb, 0, 0, image->w, image->h); + fz_pixmap *rgb = fz_new_pixmap(fz_device_rgb, image->w, image->h); fz_convert_pixmap(image, rgb); rgb->xres = image->xres; rgb->yres = image->yres; |