summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2013-05-16 22:29:27 +0200
committerRobin Watts <robin.watts@artifex.com>2013-05-16 23:47:14 +0100
commit93bd1ff05bf315ed11b305d32eb510bd9a9a7e92 (patch)
tree10c2d846ed1193624a5119853bbc2ef9651e197c /fitz
parent558ad511446cfa1d70891d9e7c9fb1ba942d3d9a (diff)
downloadmupdf-93bd1ff05bf315ed11b305d32eb510bd9a9a7e92.tar.xz
Add colorspace context.
To prepare for color management, we have to make the device colorspaces per-context and able to be overridden by users.
Diffstat (limited to 'fitz')
-rw-r--r--fitz/base_context.c4
-rw-r--r--fitz/dev_svg.c10
-rw-r--r--fitz/fitz-internal.h5
-rw-r--r--fitz/fitz.h42
-rw-r--r--fitz/image_jpeg.c6
-rw-r--r--fitz/image_jpx.c8
-rw-r--r--fitz/image_png.c10
-rw-r--r--fitz/image_save.c4
-rw-r--r--fitz/image_tiff.c14
-rw-r--r--fitz/res_colorspace.c177
-rw-r--r--fitz/res_font.c2
-rw-r--r--fitz/res_pixmap.c4
12 files changed, 201 insertions, 85 deletions
diff --git a/fitz/base_context.c b/fitz/base_context.c
index 8189efb2..683ad7dd 100644
--- a/fitz/base_context.c
+++ b/fitz/base_context.c
@@ -52,6 +52,7 @@ fz_free_context(fz_context *ctx)
fz_drop_glyph_cache_context(ctx);
fz_drop_store_context(ctx);
fz_free_aa_context(ctx);
+ fz_drop_colorspace_context(ctx);
fz_drop_font_context(ctx);
fz_drop_id_context(ctx);
@@ -138,6 +139,7 @@ fz_new_context(fz_alloc_context *alloc, fz_locks_context *locks, unsigned int ma
{
fz_new_store_context(ctx, max_store);
fz_new_glyph_cache_context(ctx);
+ fz_new_colorspace_context(ctx);
fz_new_font_context(ctx);
fz_new_id_context(ctx);
}
@@ -180,6 +182,8 @@ fz_clone_context_internal(fz_context *ctx)
new_ctx->store = fz_keep_store_context(new_ctx);
new_ctx->glyph_cache = ctx->glyph_cache;
new_ctx->glyph_cache = fz_keep_glyph_cache(new_ctx);
+ new_ctx->colorspace = ctx->colorspace;
+ new_ctx->colorspace = fz_keep_colorspace_context(new_ctx);
new_ctx->font = ctx->font;
new_ctx->font = fz_keep_font_context(new_ctx);
new_ctx->id = ctx->id;
diff --git a/fitz/dev_svg.c b/fitz/dev_svg.c
index 1b71e576..4353544d 100644
--- a/fitz/dev_svg.c
+++ b/fitz/dev_svg.c
@@ -112,7 +112,7 @@ svg_dev_fill_color(svg_device *sdev, fz_colorspace *colorspace, float *color, fl
fz_output *out = sdev->out;
float rgb[FZ_MAX_COLORS];
- if (colorspace != fz_device_rgb)
+ if (colorspace != fz_device_rgb(ctx))
{
/* If it's not rgb, make it rgb */
colorspace->to_rgb(ctx, colorspace, color, rgb);
@@ -136,7 +136,7 @@ svg_dev_stroke_color(svg_device *sdev, fz_colorspace *colorspace, float *color,
fz_output *out = sdev->out;
float rgb[FZ_MAX_COLORS];
- if (colorspace != fz_device_rgb)
+ if (colorspace != fz_device_rgb(ctx))
{
/* If it's not rgb, make it rgb */
colorspace->to_rgb(ctx, colorspace, color, rgb);
@@ -273,7 +273,7 @@ svg_dev_clip_stroke_path(fz_device *dev, fz_path *path, const fz_rect *rect, fz_
fz_printf(out, "<path");
svg_dev_ctm(sdev, ctm);
svg_dev_stroke_state(sdev, stroke);
- svg_dev_stroke_color(sdev, fz_device_rgb, white, 1);
+ svg_dev_stroke_color(sdev, fz_device_rgb(ctx), white, 1);
svg_dev_path(sdev, path);
fz_printf(out, "/>\n</mask>\n<g mask=\"url(#ma%d)\">\n", num);
}
@@ -319,7 +319,7 @@ svg_dev_clip_text(fz_device *dev, fz_text *text, const fz_matrix *ctm, int accum
fz_printf(out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\" maskUnits=\"userSpaceOnUse\" maskContentUnits=\"userSpaceOnUse\" >\n",
num, bounds.x0, bounds.y0, bounds.x1 - bounds.x0, bounds.y1 - bounds.y0);
fz_printf(out, "<text");
- svg_dev_fill_color(sdev, fz_device_rgb, white, 1.0f);
+ svg_dev_fill_color(sdev, fz_device_rgb(ctx), white, 1.0f);
svg_dev_text(sdev, ctm, text);
fz_printf(out, "</mask>\n<g mask=\"url(#ma%d)\">\n", num);
}
@@ -340,7 +340,7 @@ svg_dev_clip_stroke_text(fz_device *dev, fz_text *text, fz_stroke_state *stroke,
num, bounds.x0, bounds.y0, bounds.x1 - bounds.x0, bounds.y1 - bounds.y0);
fz_printf(out, "<text");
svg_dev_stroke_state(sdev, stroke);
- svg_dev_stroke_color(sdev, fz_device_rgb, white, 1.0f);
+ svg_dev_stroke_color(sdev, fz_device_rgb(ctx), white, 1.0f);
svg_dev_text(sdev, ctm, text);
fz_printf(out, "</mask>\n<g mask=\"url(#ma%d)\">\n", num);
}
diff --git a/fitz/fitz-internal.h b/fitz/fitz-internal.h
index 24895591..25ab6860 100644
--- a/fitz/fitz-internal.h
+++ b/fitz/fitz-internal.h
@@ -1060,9 +1060,12 @@ fz_colorspace *fz_keep_colorspace(fz_context *ctx, fz_colorspace *colorspace);
void fz_drop_colorspace(fz_context *ctx, fz_colorspace *colorspace);
void fz_free_colorspace_imp(fz_context *ctx, fz_storable *colorspace);
-
void fz_convert_color(fz_context *ctx, fz_colorspace *dsts, float *dstv, fz_colorspace *srcs, float *srcv);
+void fz_new_colorspace_context(fz_context *ctx);
+fz_colorspace_context *fz_keep_colorspace_context(fz_context *ctx);
+void fz_drop_colorspace_context(fz_context *ctx);
+
typedef struct fz_color_converter_s fz_color_converter;
/* This structure is public because it allows us to avoid dynamic allocations.
diff --git a/fitz/fitz.h b/fitz/fitz.h
index f18efe6b..05bf85fb 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -204,6 +204,7 @@ typedef struct fz_error_context_s fz_error_context;
typedef struct fz_id_context_s fz_id_context;
typedef struct fz_warn_context_s fz_warn_context;
typedef struct fz_font_context_s fz_font_context;
+typedef struct fz_colorspace_context_s fz_colorspace_context;
typedef struct fz_aa_context_s fz_aa_context;
typedef struct fz_locks_context_s fz_locks_context;
typedef struct fz_store_s fz_store;
@@ -299,6 +300,7 @@ struct fz_context_s
fz_error_context *error;
fz_warn_context *warn;
fz_font_context *font;
+ fz_colorspace_context *colorspace;
fz_aa_context *aa;
fz_store *store;
fz_glyph_cache *glyph_cache;
@@ -1428,28 +1430,44 @@ fz_colorspace *fz_find_device_colorspace(fz_context *ctx, char *name);
int fz_colorspace_is_indexed(fz_colorspace *cs);
/*
- fz_device_gray: Abstract colorspace representing device specific
- gray.
+ fz_device_gray: Get colorspace representing device specific gray.
*/
-extern fz_colorspace *fz_device_gray;
+fz_colorspace *fz_device_gray(fz_context *ctx);
/*
- fz_device_rgb: Abstract colorspace representing device specific
- rgb.
+ fz_device_rgb: Get colorspace representing device specific rgb.
*/
-extern fz_colorspace *fz_device_rgb;
+fz_colorspace *fz_device_rgb(fz_context *ctx);
/*
- fz_device_bgr: Abstract colorspace representing device specific
- bgr.
+ fz_device_bgr: Get colorspace representing device specific bgr.
*/
-extern fz_colorspace *fz_device_bgr;
+fz_colorspace *fz_device_bgr(fz_context *ctx);
/*
- fz_device_cmyk: Abstract colorspace representing device specific
- CMYK.
+ fz_device_cmyk: Get colorspace representing device specific CMYK.
*/
-extern fz_colorspace *fz_device_cmyk;
+fz_colorspace *fz_device_cmyk(fz_context *ctx);
+
+/*
+ fz_set_device_gray: Set colorspace representing device specific gray.
+*/
+void fz_set_device_gray(fz_context *ctx, fz_colorspace *cs);
+
+/*
+ fz_set_device_rgb: Set colorspace representing device specific rgb.
+*/
+void fz_set_device_rgb(fz_context *ctx, fz_colorspace *cs);
+
+/*
+ fz_set_device_bgr: Set colorspace representing device specific bgr.
+*/
+void fz_set_device_bgr(fz_context *ctx, fz_colorspace *cs);
+
+/*
+ fz_set_device_cmyk: Set colorspace representing device specific CMYK.
+*/
+void fz_set_device_cmyk(fz_context *ctx, fz_colorspace *cs);
/*
Pixmaps represent a set of pixels for a 2 dimensional region of a
diff --git a/fitz/image_jpeg.c b/fitz/image_jpeg.c
index c6ff2033..bd7a6d5b 100644
--- a/fitz/image_jpeg.c
+++ b/fitz/image_jpeg.c
@@ -70,11 +70,11 @@ fz_load_jpeg_info(fz_context *ctx, unsigned char *rbuf, int rlen, int *xp, int *
jpeg_read_header(&cinfo, 1);
if (cinfo.num_components == 1)
- *cspacep = fz_device_gray;
+ *cspacep = fz_device_gray(ctx);
else if (cinfo.num_components == 3)
- *cspacep = fz_device_rgb;
+ *cspacep = fz_device_rgb(ctx);
else if (cinfo.num_components == 4)
- *cspacep = fz_device_cmyk;
+ *cspacep = fz_device_cmyk(ctx);
else
fz_throw(ctx, "bad number of components in jpeg: %d", cinfo.num_components);
diff --git a/fitz/image_jpx.c b/fitz/image_jpx.c
index 0b3df098..ac232220 100644
--- a/fitz/image_jpx.c
+++ b/fitz/image_jpx.c
@@ -117,9 +117,9 @@ fz_load_jpx(fz_context *ctx, unsigned char *data, int size, fz_colorspace *defcs
{
switch (n)
{
- case 1: colorspace = fz_device_gray; break;
- case 3: colorspace = fz_device_rgb; break;
- case 4: colorspace = fz_device_cmyk; break;
+ case 1: colorspace = fz_device_gray(ctx); break;
+ case 3: colorspace = fz_device_rgb(ctx); break;
+ case 4: colorspace = fz_device_cmyk(ctx); break;
}
}
@@ -158,7 +158,7 @@ fz_load_jpx(fz_context *ctx, unsigned char *data, int size, fz_colorspace *defcs
{
if (n == 4)
{
- fz_pixmap *tmp = fz_new_pixmap(ctx, fz_device_rgb, w, h);
+ fz_pixmap *tmp = fz_new_pixmap(ctx, fz_device_rgb(ctx), w, h);
fz_convert_pixmap(ctx, tmp, img);
fz_drop_pixmap(ctx, img);
img = tmp;
diff --git a/fitz/image_png.c b/fitz/image_png.c
index 7eebdced..1adaaf7a 100644
--- a/fitz/image_png.c
+++ b/fitz/image_png.c
@@ -485,7 +485,7 @@ png_read_image(fz_context *ctx, struct info *info, unsigned char *p, unsigned in
static fz_pixmap *
png_expand_palette(fz_context *ctx, struct info *info, fz_pixmap *src)
{
- fz_pixmap *dst = fz_new_pixmap(ctx, fz_device_rgb, src->w, src->h);
+ fz_pixmap *dst = fz_new_pixmap(ctx, fz_device_rgb(ctx), src->w, src->h);
unsigned char *sp = src->samples;
unsigned char *dp = dst->samples;
unsigned int x, y;
@@ -545,9 +545,9 @@ fz_load_png(fz_context *ctx, unsigned char *p, int total)
png_read_image(ctx, &png, p, total);
if (png.n == 3 || png.n == 4)
- colorspace = fz_device_rgb;
+ colorspace = fz_device_rgb(ctx);
else
- colorspace = fz_device_gray;
+ colorspace = fz_device_gray(ctx);
stride = (png.width * png.n * png.depth + 7) / 8;
@@ -587,9 +587,9 @@ fz_load_png_info(fz_context *ctx, unsigned char *p, int total, int *wp, int *hp,
png_read_image(ctx, &png, p, total);
if (png.n == 3 || png.n == 4)
- *cspacep = fz_device_rgb;
+ *cspacep = fz_device_rgb(ctx);
else
- *cspacep = fz_device_gray;
+ *cspacep = fz_device_gray(ctx);
*wp = png.width;
*hp = png.height;
diff --git a/fitz/image_save.c b/fitz/image_save.c
index b0856507..8695002b 100644
--- a/fitz/image_save.c
+++ b/fitz/image_save.c
@@ -8,10 +8,10 @@ void fz_write_pixmap(fz_context *ctx, fz_pixmap *img, char *file, int rgb)
if (!img)
return;
- if (rgb && img->colorspace && img->colorspace != fz_device_rgb)
+ if (rgb && img->colorspace && img->colorspace != fz_device_rgb(ctx))
{
fz_irect bbox;
- converted = fz_new_pixmap_with_bbox(ctx, fz_device_rgb, fz_pixmap_bbox(ctx, img, &bbox));
+ converted = fz_new_pixmap_with_bbox(ctx, fz_device_rgb(ctx), fz_pixmap_bbox(ctx, img, &bbox));
fz_convert_pixmap(ctx, converted, img);
img = converted;
}
diff --git a/fitz/image_tiff.c b/fitz/image_tiff.c
index 0efcc622..7a372214 100644
--- a/fitz/image_tiff.c
+++ b/fitz/image_tiff.c
@@ -358,23 +358,23 @@ fz_decode_tiff_strips(struct tiff *tiff)
switch (tiff->photometric)
{
case 0: /* WhiteIsZero -- inverted */
- tiff->colorspace = fz_device_gray;
+ tiff->colorspace = fz_device_gray(tiff->ctx);
break;
case 1: /* BlackIsZero */
- tiff->colorspace = fz_device_gray;
+ tiff->colorspace = fz_device_gray(tiff->ctx);
break;
case 2: /* RGB */
- tiff->colorspace = fz_device_rgb;
+ tiff->colorspace = fz_device_rgb(tiff->ctx);
break;
case 3: /* RGBPal */
- tiff->colorspace = fz_device_rgb;
+ tiff->colorspace = fz_device_rgb(tiff->ctx);
break;
case 5: /* CMYK */
- tiff->colorspace = fz_device_cmyk;
+ tiff->colorspace = fz_device_cmyk(tiff->ctx);
break;
case 6: /* YCbCr */
/* it's probably a jpeg ... we let jpeg convert to rgb */
- tiff->colorspace = fz_device_rgb;
+ tiff->colorspace = fz_device_rgb(tiff->ctx);
break;
default:
fz_throw(tiff->ctx, "unknown photometric: %d", tiff->photometric);
@@ -809,7 +809,7 @@ fz_load_tiff(fz_context *ctx, unsigned char *buf, int len)
/* CMYK is a subtractive colorspace, we want additive for premul alpha */
if (image->n == 5)
{
- fz_pixmap *rgb = fz_new_pixmap(tiff.ctx, fz_device_rgb, image->w, image->h);
+ fz_pixmap *rgb = fz_new_pixmap(tiff.ctx, fz_device_rgb(ctx), image->w, image->h);
fz_convert_pixmap(tiff.ctx, rgb, image);
rgb->xres = image->xres;
rgb->yres = image->yres;
diff --git a/fitz/res_colorspace.c b/fitz/res_colorspace.c
index 5d8c3b02..faa6c3c1 100644
--- a/fitz/res_colorspace.c
+++ b/fitz/res_colorspace.c
@@ -169,31 +169,122 @@ static void rgb_to_cmyk(fz_context *ctx, fz_colorspace *cs, float *rgb, float *c
cmyk[3] = k;
}
-static fz_colorspace k_device_gray = { {-1, fz_free_colorspace_imp}, 0, "DeviceGray", 1, gray_to_rgb, rgb_to_gray };
-static fz_colorspace k_device_rgb = { {-1, fz_free_colorspace_imp}, 0, "DeviceRGB", 3, rgb_to_rgb, rgb_to_rgb };
-static fz_colorspace k_device_bgr = { {-1, fz_free_colorspace_imp}, 0, "DeviceRGB", 3, bgr_to_rgb, rgb_to_bgr };
-static fz_colorspace k_device_cmyk = { {-1, fz_free_colorspace_imp}, 0, "DeviceCMYK", 4, cmyk_to_rgb, rgb_to_cmyk };
+static fz_colorspace k_default_gray = { {-1, fz_free_colorspace_imp}, 0, "DeviceGray", 1, gray_to_rgb, rgb_to_gray };
+static fz_colorspace k_default_rgb = { {-1, fz_free_colorspace_imp}, 0, "DeviceRGB", 3, rgb_to_rgb, rgb_to_rgb };
+static fz_colorspace k_default_bgr = { {-1, fz_free_colorspace_imp}, 0, "DeviceRGB", 3, bgr_to_rgb, rgb_to_bgr };
+static fz_colorspace k_default_cmyk = { {-1, fz_free_colorspace_imp}, 0, "DeviceCMYK", 4, cmyk_to_rgb, rgb_to_cmyk };
-fz_colorspace *fz_device_gray = &k_device_gray;
-fz_colorspace *fz_device_rgb = &k_device_rgb;
-fz_colorspace *fz_device_bgr = &k_device_bgr;
-fz_colorspace *fz_device_cmyk = &k_device_cmyk;
+static fz_colorspace *fz_default_gray = &k_default_gray;
+static fz_colorspace *fz_default_rgb = &k_default_rgb;
+static fz_colorspace *fz_default_bgr = &k_default_bgr;
+static fz_colorspace *fz_default_cmyk = &k_default_cmyk;
+
+struct fz_colorspace_context_s
+{
+ int ctx_refs;
+ fz_colorspace *gray, *rgb, *bgr, *cmyk;
+};
+
+void fz_new_colorspace_context(fz_context *ctx)
+{
+ ctx->colorspace = fz_malloc_struct(ctx, fz_colorspace_context);
+ ctx->colorspace->ctx_refs = 1;
+ ctx->colorspace->gray = fz_default_gray;
+ ctx->colorspace->rgb = fz_default_rgb;
+ ctx->colorspace->bgr = fz_default_bgr;
+ ctx->colorspace->cmyk = fz_default_cmyk;
+}
+
+fz_colorspace_context *
+fz_keep_colorspace_context(fz_context *ctx)
+{
+ if (!ctx || !ctx->colorspace)
+ return NULL;
+ fz_lock(ctx, FZ_LOCK_ALLOC);
+ ctx->colorspace->ctx_refs++;
+ fz_unlock(ctx, FZ_LOCK_ALLOC);
+ return ctx->colorspace;
+}
+
+void fz_drop_colorspace_context(fz_context *ctx)
+{
+ int drop;
+ if (!ctx || !ctx->colorspace)
+ return;
+ fz_lock(ctx, FZ_LOCK_ALLOC);
+ drop = --ctx->colorspace->ctx_refs;
+ fz_unlock(ctx, FZ_LOCK_ALLOC);
+ if (drop == 0)
+ fz_free(ctx, ctx->colorspace);
+}
+
+fz_colorspace *
+fz_device_gray(fz_context *ctx)
+{
+ return ctx->colorspace->gray;
+}
+
+fz_colorspace *
+fz_device_rgb(fz_context *ctx)
+{
+ return ctx->colorspace->rgb;
+}
+
+fz_colorspace *
+fz_device_bgr(fz_context *ctx)
+{
+ return ctx->colorspace->bgr;
+}
+
+fz_colorspace *
+fz_device_cmyk(fz_context *ctx)
+{
+ return ctx->colorspace->cmyk;
+}
fz_colorspace *
fz_find_device_colorspace(fz_context *ctx, char *name)
{
if (!strcmp(name, "DeviceGray"))
- return fz_device_gray;
+ return fz_device_gray(ctx);
if (!strcmp(name, "DeviceRGB"))
- return fz_device_rgb;
+ return fz_device_rgb(ctx);
if (!strcmp(name, "DeviceBGR"))
- return fz_device_bgr;
+ return fz_device_bgr(ctx);
if (!strcmp(name, "DeviceCMYK"))
- return fz_device_cmyk;
+ return fz_device_cmyk(ctx);
assert(!"unknown device colorspace");
return NULL;
}
+void
+fz_set_device_gray(fz_context *ctx, fz_colorspace *cs)
+{
+ fz_drop_colorspace(ctx, ctx->colorspace->gray);
+ ctx->colorspace->gray = fz_keep_colorspace(ctx, cs);
+}
+
+void
+fz_set_device_rgb(fz_context *ctx, fz_colorspace *cs)
+{
+ fz_drop_colorspace(ctx, ctx->colorspace->rgb);
+ ctx->colorspace->rgb = fz_keep_colorspace(ctx, cs);
+}
+
+void
+fz_set_device_bgr(fz_context *ctx, fz_colorspace *cs)
+{
+ fz_drop_colorspace(ctx, ctx->colorspace->bgr);
+ ctx->colorspace->bgr = fz_keep_colorspace(ctx, cs);
+}
+
+void
+fz_set_device_cmyk(fz_context *ctx, fz_colorspace *cs)
+{
+ fz_drop_colorspace(ctx, ctx->colorspace->cmyk);
+ ctx->colorspace->cmyk = fz_keep_colorspace(ctx, cs);
+}
+
int
fz_colorspace_is_indexed(fz_colorspace *cs)
{
@@ -861,35 +952,35 @@ fz_convert_pixmap(fz_context *ctx, fz_pixmap *dp, fz_pixmap *sp)
dp->interpolate = sp->interpolate;
- if (ss == fz_device_gray)
+ if (ss == fz_default_gray)
{
- if (ds == fz_device_rgb) fast_gray_to_rgb(dp, sp);
- else if (ds == fz_device_bgr) fast_gray_to_rgb(dp, sp); /* bgr == rgb here */
- else if (ds == fz_device_cmyk) fast_gray_to_cmyk(dp, sp);
+ if (ds == fz_default_rgb) fast_gray_to_rgb(dp, sp);
+ else if (ds == fz_default_bgr) fast_gray_to_rgb(dp, sp); /* bgr == rgb here */
+ else if (ds == fz_default_cmyk) fast_gray_to_cmyk(dp, sp);
else fz_std_conv_pixmap(ctx, dp, sp);
}
- else if (ss == fz_device_rgb)
+ else if (ss == fz_default_rgb)
{
- if (ds == fz_device_gray) fast_rgb_to_gray(dp, sp);
- else if (ds == fz_device_bgr) fast_rgb_to_bgr(dp, sp);
- else if (ds == fz_device_cmyk) fast_rgb_to_cmyk(dp, sp);
+ if (ds == fz_default_gray) fast_rgb_to_gray(dp, sp);
+ else if (ds == fz_default_bgr) fast_rgb_to_bgr(dp, sp);
+ else if (ds == fz_default_cmyk) fast_rgb_to_cmyk(dp, sp);
else fz_std_conv_pixmap(ctx, dp, sp);
}
- else if (ss == fz_device_bgr)
+ else if (ss == fz_default_bgr)
{
- if (ds == fz_device_gray) fast_bgr_to_gray(dp, sp);
- else if (ds == fz_device_rgb) fast_rgb_to_bgr(dp, sp); /* bgr = rgb here */
- else if (ds == fz_device_cmyk) fast_bgr_to_cmyk(sp, dp);
+ if (ds == fz_default_gray) fast_bgr_to_gray(dp, sp);
+ else if (ds == fz_default_rgb) fast_rgb_to_bgr(dp, sp); /* bgr = rgb here */
+ else if (ds == fz_default_cmyk) fast_bgr_to_cmyk(sp, dp);
else fz_std_conv_pixmap(ctx, dp, sp);
}
- else if (ss == fz_device_cmyk)
+ else if (ss == fz_default_cmyk)
{
- if (ds == fz_device_gray) fast_cmyk_to_gray(dp, sp);
- else if (ds == fz_device_bgr) fast_cmyk_to_bgr(ctx, dp, sp);
- else if (ds == fz_device_rgb) fast_cmyk_to_rgb(ctx, dp, sp);
+ if (ds == fz_default_gray) fast_cmyk_to_gray(dp, sp);
+ else if (ds == fz_default_bgr) fast_cmyk_to_bgr(ctx, dp, sp);
+ else if (ds == fz_default_rgb) fast_cmyk_to_rgb(ctx, dp, sp);
else fz_std_conv_pixmap(ctx, dp, sp);
}
@@ -1027,47 +1118,47 @@ void fz_find_color_converter(fz_color_converter *cc, fz_context *ctx, fz_colorsp
cc->ctx = ctx;
cc->ds = ds;
cc->ss = ss;
- if (ss == fz_device_gray)
+ if (ss == fz_default_gray)
{
- if ((ds == fz_device_rgb) || (ds == fz_device_bgr))
+ if ((ds == fz_default_rgb) || (ds == fz_default_bgr))
cc->convert = g2rgb;
- else if (ds == fz_device_cmyk)
+ else if (ds == fz_default_cmyk)
cc->convert = g2cmyk;
else
cc->convert = std_conv_color;
}
- else if (ss == fz_device_rgb)
+ else if (ss == fz_default_rgb)
{
- if (ds == fz_device_gray)
+ if (ds == fz_default_gray)
cc->convert = rgb2g;
- else if (ds == fz_device_bgr)
+ else if (ds == fz_default_bgr)
cc->convert = rgb2bgr;
- else if (ds == fz_device_cmyk)
+ else if (ds == fz_default_cmyk)
cc->convert = rgb2cmyk;
else
cc->convert = std_conv_color;
}
- else if (ss == fz_device_bgr)
+ else if (ss == fz_default_bgr)
{
- if (ds == fz_device_gray)
+ if (ds == fz_default_gray)
cc->convert = bgr2g;
- else if (ds == fz_device_rgb)
+ else if (ds == fz_default_rgb)
cc->convert = rgb2bgr;
- else if (ds == fz_device_cmyk)
+ else if (ds == fz_default_cmyk)
cc->convert = bgr2cmyk;
else
cc->convert = std_conv_color;
}
- else if (ss == fz_device_cmyk)
+ else if (ss == fz_default_cmyk)
{
- if (ds == fz_device_gray)
+ if (ds == fz_default_gray)
cc->convert = cmyk2g;
- else if (ds == fz_device_rgb)
+ else if (ds == fz_default_rgb)
cc->convert = cmyk2rgb;
- else if (ds == fz_device_bgr)
+ else if (ds == fz_default_bgr)
cc->convert = cmyk2bgr;
else
cc->convert = std_conv_color;
diff --git a/fitz/res_font.c b/fitz/res_font.c
index edc8c054..8fb51377 100644
--- a/fitz/res_font.c
+++ b/fitz/res_font.c
@@ -954,7 +954,7 @@ fz_render_t3_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm
fz_irect_from_rect(&bbox, &bounds);
fz_intersect_irect(&bbox, &scissor);
- glyph = fz_new_pixmap_with_bbox(ctx, model ? model : fz_device_gray, &bbox);
+ glyph = fz_new_pixmap_with_bbox(ctx, model ? model : fz_device_gray(ctx), &bbox);
fz_clear_pixmap(ctx, glyph);
fz_concat(&ctm, &font->t3matrix, trm);
diff --git a/fitz/res_pixmap.c b/fitz/res_pixmap.c
index 6a931486..18d05231 100644
--- a/fitz/res_pixmap.c
+++ b/fitz/res_pixmap.c
@@ -694,9 +694,9 @@ fz_image_as_png(fz_context *ctx, fz_image *image, int w, int h)
fz_try(ctx)
{
- if (pix->colorspace != fz_device_gray || pix->colorspace != fz_device_rgb)
+ if (pix->colorspace != fz_device_gray(ctx) || pix->colorspace != fz_device_rgb(ctx))
{
- fz_pixmap *pix2 = fz_new_pixmap(ctx, fz_device_rgb, pix->w, pix->h);
+ fz_pixmap *pix2 = fz_new_pixmap(ctx, fz_device_rgb(ctx), pix->w, pix->h);
fz_convert_pixmap(ctx, pix2, pix);
fz_drop_pixmap(ctx, pix);
pix = pix2;