[poppler] Branch 'poppler-0.16' - poppler/CairoOutputDev.cc poppler/CairoOutputDev.h
Carlos Garcia Campos
carlosgc at kemper.freedesktop.org
Tue Jan 4 01:19:27 PST 2011
poppler/CairoOutputDev.cc | 46 +++++++++++++++++++++++++++++++---------------
poppler/CairoOutputDev.h | 1 +
2 files changed, 32 insertions(+), 15 deletions(-)
New commits:
commit cc48dc71891e7477199a86967af9b0ac93302f72
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Fri Dec 31 12:11:40 2010 +1030
cairo: Don't set JPX mime data if the stream specifies a colorspace
The stream colorspace overides, and may be different to, the
colorspace in the JPX data.
https://bugs.freedesktop.org/show_bug.cgi?id=32746
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 0507f8c..bc0bfb9 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -2283,6 +2283,36 @@ GBool CairoOutputDev::getStreamData (Stream *str, char **buffer, int *length)
return gTrue;
}
+void CairoOutputDev::setMimeData(Stream *str, cairo_surface_t *image)
+{
+ char *strBuffer;
+ int len;
+ Object obj;
+
+ if (!printing || !(str->getKind() == strDCT || str->getKind() == strJPX))
+ return;
+
+ // colorspace in stream dict may be different from colorspace in jpx
+ // data
+ if (str->getKind() == strJPX) {
+ GBool hasColorSpace = !str->getDict()->lookup("ColorSpace", &obj)->isNull();
+ obj.free();
+ if (hasColorSpace)
+ return;
+ }
+
+ if (getStreamData (str->getNextStream(), &strBuffer, &len)) {
+ cairo_status_t st;
+ st = cairo_surface_set_mime_data (image,
+ str->getKind() == strDCT ?
+ CAIRO_MIME_TYPE_JPEG : CAIRO_MIME_TYPE_JP2,
+ (const unsigned char *)strBuffer, len,
+ gfree, strBuffer);
+ if (st)
+ gfree (strBuffer);
+ }
+}
+
void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
int width, int height,
GfxImageColorMap *colorMap,
@@ -2396,21 +2426,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
cairo_surface_mark_dirty (image);
- if (printing && (str->getKind() == strDCT || str->getKind() == strJPX)) {
- char *strBuffer;
- int len;
-
- if (getStreamData (str->getNextStream(), &strBuffer, &len)) {
- cairo_status_t st;
- st = cairo_surface_set_mime_data (image,
- str->getKind() == strDCT ?
- CAIRO_MIME_TYPE_JPEG : CAIRO_MIME_TYPE_JP2,
- (const unsigned char *)strBuffer, len,
- gfree, strBuffer);
- if (st)
- gfree (strBuffer);
- }
- }
+ setMimeData(str, image);
pattern = cairo_pattern_create_for_surface (image);
cairo_surface_destroy (image);
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 26efadc..30acf81 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -275,6 +275,7 @@ protected:
cairo_filter_t getFilterForSurface(cairo_surface_t *image,
GBool interpolate);
GBool getStreamData (Stream *str, char **buffer, int *length);
+ void setMimeData(Stream *str, cairo_surface_t *image);
GfxRGB fill_color, stroke_color;
cairo_pattern_t *fill_pattern, *stroke_pattern;
More information about the poppler
mailing list