Index: poppler/CairoOutputDev.cc =================================================================== RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.cc,v retrieving revision 1.27 diff -u -r1.27 CairoOutputDev.cc --- poppler/CairoOutputDev.cc 26 Jan 2006 19:25:07 -0000 1.27 +++ poppler/CairoOutputDev.cc 16 Feb 2006 17:19:04 -0000 @@ -481,6 +481,26 @@ int invert_bit; int row_stride; + ctm = state->getCTM(); + LOG (printf ("drawImageMask %dx%d, matrix: %f, %f, %f, %f, %f, %f\n", + width, height, ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5])); + matrix.xx = ctm[0] / width; + matrix.xy = -ctm[2] / height; + matrix.yx = ctm[1] / width; + matrix.yy = -ctm[3] / height; + matrix.x0 = ctm[2] + ctm[4]; + matrix.y0 = ctm[3] + ctm[5]; + + /* work around a cairo bug when scaling 1x1 surfaces */ + if (width == 1 && height == 1) { + cairo_save (cairo); + cairo_set_matrix (cairo, &matrix); + cairo_rectangle (cairo, 0., 0., 1., 1.); + cairo_fill (cairo); + cairo_restore (cairo); + return; + } + row_stride = (width + 3) & ~3; buffer = (unsigned char *) malloc (height * row_stride); if (buffer == NULL) { @@ -514,19 +534,14 @@ if (pattern == NULL) return; - ctm = state->getCTM(); - LOG (printf ("drawImageMask %dx%d, matrix: %f, %f, %f, %f, %f, %f\n", - width, height, ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5])); - matrix.xx = ctm[0] / width; - matrix.xy = -ctm[2] / height; - matrix.yx = ctm[1] / width; - matrix.yy = -ctm[3] / height; - matrix.x0 = ctm[2] + ctm[4]; - matrix.y0 = ctm[3] + ctm[5]; cairo_matrix_invert (&matrix); cairo_pattern_set_matrix (pattern, &matrix); + /* we should actually be using CAIRO_FILTER_NEAREST here. However, + * cairo doesn't yet do minifaction filtering causing scaled down + * images with CAIRO_FILTER_NEAREST to look really bad */ cairo_pattern_set_filter (pattern, CAIRO_FILTER_BEST); + /* FIXME: Doesn't the image mask support any colorspace? */ cairo_set_source (cairo, fill_pattern); cairo_mask (cairo, pattern);