summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-04-06 20:36:09 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-04-06 20:36:09 +0200
commit71b44f14fd09fe3cb404f6f9225b3e4987328e15 (patch)
treee96d368b12513abc40f34f3534a9266125f651b5
parent4a8af0a2b86fcb737cb7162b6e6926540f2f1af2 (diff)
downloadmupdf-71b44f14fd09fe3cb404f6f9225b3e4987328e15.tar.xz
Rename span to stride, and add gray->bgr fast path image drawing.
-rw-r--r--draw/draw_device.c11
-rw-r--r--fitz/fitz.h2
-rw-r--r--fitz/res_bitmap.c14
-rw-r--r--fitz/res_halftone.c14
4 files changed, 21 insertions, 20 deletions
diff --git a/draw/draw_device.c b/draw/draw_device.c
index e49fb04d..fe93183d 100644
--- a/draw/draw_device.c
+++ b/draw/draw_device.c
@@ -531,7 +531,7 @@ fz_transform_pixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int
{
fz_pixmap *scaled;
- if ((ctm->a != 0) && (ctm->b == 0) && (ctm->c == 0) && (ctm->d != 0))
+ if (ctm->a != 0 && ctm->b == 0 && ctm->c == 0 && ctm->d != 0)
{
/* Unrotated or X flip or Yflip or XYflip */
scaled = fz_scale_pixmap(image, ctm->e, ctm->f, ctm->a, ctm->d);
@@ -543,7 +543,7 @@ fz_transform_pixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int
ctm->f = scaled->y;
return scaled;
}
- if ((ctm->a == 0) && (ctm->b != 0) && (ctm->c != 0) && (ctm->d == 0))
+ if (ctm->a == 0 && ctm->b != 0 && ctm->c != 0 && ctm->d == 0)
{
/* Other orthogonal flip/rotation cases */
scaled = fz_scale_pixmap(image, ctm->f, ctm->e, ctm->b, ctm->c);
@@ -556,7 +556,7 @@ fz_transform_pixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int
return scaled;
}
/* Downscale, non rectilinear case */
- if ((dx > 0) && (dy > 0))
+ if (dx > 0 && dy > 0)
{
scaled = fz_scale_pixmap(image, 0, 0, (float)dx, (float)dy);
return scaled;
@@ -617,9 +617,10 @@ fz_draw_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha)
if (image->colorspace != model)
{
- if (image->colorspace == fz_device_gray && model == fz_device_rgb)
+ if ((image->colorspace == fz_device_gray && model == fz_device_rgb) ||
+ (image->colorspace == fz_device_gray && model == fz_device_bgr))
{
- /* We have special case rendering code for gray -> rgb */
+ /* We have special case rendering code for gray -> rgb/bgr */
}
else
{
diff --git a/fitz/fitz.h b/fitz/fitz.h
index 749c8919..98047d71 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -710,7 +710,7 @@ typedef struct fz_bitmap_s fz_bitmap;
struct fz_bitmap_s
{
int refs;
- int w, h, span, n;
+ int w, h, stride, n;
unsigned char *samples;
};
diff --git a/fitz/res_bitmap.c b/fitz/res_bitmap.c
index 57784076..0b852af2 100644
--- a/fitz/res_bitmap.c
+++ b/fitz/res_bitmap.c
@@ -12,9 +12,9 @@ fz_new_bitmap(int w, int h, int n)
bit->n = n;
/* Span is 32 bit aligned. We may want to make this 64 bit if we
* use SSE2 etc. */
- bit->span = ((n*w+31)&~31)>>3;
+ bit->stride = ((n * w + 31) & ~31) >> 3;
- bit->samples = fz_calloc(h, bit->span);
+ bit->samples = fz_calloc(h, bit->stride);
return bit;
}
@@ -39,7 +39,7 @@ fz_drop_bitmap(fz_bitmap *bit)
void
fz_clear_bitmap(fz_bitmap *bit)
{
- memset(bit->samples, 0, bit->span * bit->h);
+ memset(bit->samples, 0, bit->stride * bit->h);
}
/*
@@ -51,7 +51,7 @@ fz_write_pbm(fz_bitmap *bitmap, char *filename)
{
FILE *fp;
unsigned char *p;
- int h, bytespan;
+ int h, bytestride;
fp = fopen(filename, "wb");
if (!fp)
@@ -64,11 +64,11 @@ fz_write_pbm(fz_bitmap *bitmap, char *filename)
p = bitmap->samples;
h = bitmap->h;
- bytespan = (bitmap->w+7)>>3;
+ bytestride = (bitmap->w + 7) >> 3;
while (h--)
{
- fwrite(p, 1, bytespan, fp);
- p += bitmap->span;
+ fwrite(p, 1, bytestride, fp);
+ p += bitmap->stride;
}
fclose(fp);
diff --git a/fitz/res_halftone.c b/fitz/res_halftone.c
index 180c9c0a..139be112 100644
--- a/fitz/res_halftone.c
+++ b/fitz/res_halftone.c
@@ -173,15 +173,15 @@ fz_bitmap *fz_halftone_pixmap(fz_pixmap *pix, fz_halftone *ht)
{
fz_bitmap *out;
unsigned char *ht_line, *o, *p;
- int w, h, x, y, n, pspan, ospan;
+ int w, h, x, y, n, pstride, ostride;
- if ((pix == NULL) || (ht == NULL))
+ if (pix == NULL || ht == NULL)
return NULL;
assert(pix->n == 2); /* Mono + Alpha */
n = pix->n-1; /* Remove alpha */
- ht_line = fz_malloc(sizeof(unsigned char)*pix->w*n);
+ ht_line = fz_malloc(pix->w * n);
out = fz_new_bitmap(pix->w, pix->h, n);
o = out->samples;
p = pix->samples;
@@ -190,14 +190,14 @@ fz_bitmap *fz_halftone_pixmap(fz_pixmap *pix, fz_halftone *ht)
x = pix->x;
y = pix->y;
w = pix->w;
- ospan = out->span;
- pspan = pix->w * pix->n;
+ ostride = out->stride;
+ pstride = pix->w * pix->n;
while (h--)
{
make_ht_line(ht_line, ht, x, y++, w);
do_threshold_1(ht_line, p, o, w);
- o += ospan;
- p += pspan;
+ o += ostride;
+ p += pstride;
}
return out;
}