diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-06-22 21:25:09 +0200 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-06-22 21:25:09 +0200 |
commit | c0eb706ac7fe12fb55705581296f5bab9eaf424f (patch) | |
tree | fd1ae21264cbbf8f398bd05d3e379479a1247f45 | |
parent | dccc859e937cedd63e5b6450f65a4d91786b5332 (diff) | |
download | mupdf-c0eb706ac7fe12fb55705581296f5bab9eaf424f.tar.xz |
Make the color conversions in dev_draw general for n-component colors.
-rw-r--r-- | fitz/dev_draw.c | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/fitz/dev_draw.c b/fitz/dev_draw.c index 2698f22d..89f60c55 100644 --- a/fitz/dev_draw.c +++ b/fitz/dev_draw.c @@ -76,7 +76,10 @@ fz_drawfillpath(void *user, fz_path *path, int evenodd, fz_matrix ctm, fz_drawdevice *dev = user; float expansion = fz_matrixexpansion(ctm); float flatness = 0.3f / expansion; + unsigned char argb[FZ_MAXCOLORS + 1]; + float rgb[FZ_MAXCOLORS]; fz_bbox bbox; + int i; fz_resetgel(dev->gel, dev->scissor); fz_fillpath(dev->gel, path, ctm, flatness); @@ -90,13 +93,10 @@ fz_drawfillpath(void *user, fz_path *path, int evenodd, fz_matrix ctm, if (dev->model) { - unsigned char argb[4]; - float rgb[3]; fz_convertcolor(colorspace, color, dev->model, rgb); argb[0] = alpha * 255; - argb[1] = rgb[0] * 255; - argb[2] = rgb[1] * 255; - argb[3] = rgb[2] * 255; + for (i = 0; i < dev->model->n; i++) + argb[i + 1] = rgb[i] * 255; fz_scanconvert(dev->gel, dev->ael, evenodd, bbox, dev->dest, argb, nil, nil); } else @@ -113,7 +113,10 @@ fz_drawstrokepath(void *user, fz_path *path, fz_strokestate *stroke, fz_matrix c float expansion = fz_matrixexpansion(ctm); float flatness = 0.3f / expansion; float linewidth = stroke->linewidth; + unsigned char argb[FZ_MAXCOLORS + 1]; + float rgb[FZ_MAXCOLORS]; fz_bbox bbox; + int i; if (linewidth * expansion < 0.1f) linewidth = 1 / expansion; @@ -133,13 +136,10 @@ fz_drawstrokepath(void *user, fz_path *path, fz_strokestate *stroke, fz_matrix c if (dev->model) { - unsigned char argb[4]; - float rgb[3]; fz_convertcolor(colorspace, color, dev->model, rgb); argb[0] = alpha * 255; - argb[1] = rgb[0] * 255; - argb[2] = rgb[1] * 255; - argb[3] = rgb[2] * 255; + for (i = 0; i < dev->model->n; i++) + argb[i + 1] = rgb[i] * 255; fz_scanconvert(dev->gel, dev->ael, 0, bbox, dev->dest, argb, nil, nil); } else @@ -300,25 +300,18 @@ fz_drawfilltext(void *user, fz_text *text, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { fz_drawdevice *dev = user; + unsigned char argb[FZ_MAXCOLORS + 1]; + float rgb[FZ_MAXCOLORS]; fz_matrix tm, trm; fz_pixmap *glyph; int i, x, y, gid; - unsigned char tmp[4]; - unsigned char *argb; if (dev->model) { - float rgb[3]; fz_convertcolor(colorspace, color, dev->model, rgb); - tmp[0] = alpha * 255; - tmp[1] = rgb[0] * 255; - tmp[2] = rgb[1] * 255; - tmp[3] = rgb[2] * 255; - argb = tmp; - } - else - { - argb = nil; + argb[0] = alpha * 255; + for (i = 0; i < dev->model->n; i++) + argb[i + 1] = rgb[i] * 255; } tm = text->trm; @@ -340,7 +333,10 @@ fz_drawfilltext(void *user, fz_text *text, fz_matrix ctm, glyph = fz_renderglyph(dev->cache, text->font, gid, trm); if (glyph) { - drawglyph(argb, dev->dest, glyph, x, y, dev->scissor); + if (dev->model) + drawglyph(argb, dev->dest, glyph, x, y, dev->scissor); + else + drawglyph(nil, dev->dest, glyph, x, y, dev->scissor); fz_droppixmap(glyph); } } @@ -592,10 +588,13 @@ fz_drawfillimagemask(void *user, fz_pixmap *image, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { fz_drawdevice *dev = user; + unsigned char argb[FZ_MAXCOLORS + 1]; + float rgb[FZ_MAXCOLORS]; fz_bbox bbox; int dx, dy; fz_pixmap *scaled = nil; fz_matrix invmat; + int i; calcimagestate(dev, image, ctm, &bbox, &invmat, &dx, &dy); @@ -610,13 +609,10 @@ fz_drawfillimagemask(void *user, fz_pixmap *image, fz_matrix ctm, if (dev->dest->colorspace) { - unsigned char argb[4]; - float rgb[3]; fz_convertcolor(colorspace, color, dev->model, rgb); argb[0] = alpha * 255; - argb[1] = rgb[0] * 255; - argb[2] = rgb[1] * 255; - argb[3] = rgb[2] * 255; + for (i = 0; i < dev->model->n; i++) + argb[i + 1] = rgb[i] * 255; fz_scanconvert(dev->gel, dev->ael, 0, bbox, dev->dest, argb, image, &invmat); } else |