|
|
c2e870 |
--- poppler-0.26.5/poppler/CairoOutputDev.cc
|
|
|
c2e870 |
+++ poppler-0.26.5/poppler/CairoOutputDev.cc
|
|
|
c2e870 |
@@ -2571,7 +2571,11 @@ void CairoOutputDev::drawSoftMaskedImage
|
|
|
c2e870 |
|
|
|
c2e870 |
cairo_surface_mark_dirty (image);
|
|
|
c2e870 |
|
|
|
c2e870 |
+ cairo_surface_set_user_data(image, (const cairo_user_data_key_t *) 0x1, state, NULL);
|
|
|
c2e870 |
+ cairo_surface_set_user_data(image, (const cairo_user_data_key_t *) 0x2, colorMap, NULL);
|
|
|
c2e870 |
setMimeData(str, ref, image);
|
|
|
c2e870 |
+ cairo_surface_set_user_data(image, (const cairo_user_data_key_t *) 0x2, NULL, NULL);
|
|
|
c2e870 |
+ cairo_surface_set_user_data(image, (const cairo_user_data_key_t *) 0x1, NULL, NULL);
|
|
|
c2e870 |
|
|
|
c2e870 |
pattern = cairo_pattern_create_for_surface (image);
|
|
|
c2e870 |
cairo_surface_destroy (image);
|
|
|
c2e870 |
@@ -2674,24 +2678,72 @@ GBool CairoOutputDev::getStreamData (Str
|
|
|
c2e870 |
return gTrue;
|
|
|
c2e870 |
}
|
|
|
c2e870 |
|
|
|
c2e870 |
+static GBool colorMapHasIdentityDecodeMap(GfxImageColorMap *colorMap)
|
|
|
c2e870 |
+{
|
|
|
c2e870 |
+ for (int i = 0; i < colorMap->getNumPixelComps(); i++) {
|
|
|
c2e870 |
+ if (colorMap->getDecodeLow(i) != 0.0 || colorMap->getDecodeHigh(i) != 1.0)
|
|
|
c2e870 |
+ return gFalse;
|
|
|
c2e870 |
+ }
|
|
|
c2e870 |
+ return gTrue;
|
|
|
c2e870 |
+}
|
|
|
c2e870 |
+
|
|
|
c2e870 |
void CairoOutputDev::setMimeData(Stream *str, Object *ref, cairo_surface_t *image)
|
|
|
c2e870 |
{
|
|
|
c2e870 |
char *strBuffer;
|
|
|
c2e870 |
int len;
|
|
|
c2e870 |
Object obj;
|
|
|
c2e870 |
+ GfxColorSpace *colorSpace = NULL;
|
|
|
c2e870 |
+ GfxState *state = NULL;
|
|
|
c2e870 |
+ GfxImageColorMap *colorMap = NULL;
|
|
|
c2e870 |
+
|
|
|
c2e870 |
+ if (image != NULL)
|
|
|
c2e870 |
+ {
|
|
|
c2e870 |
+ state = (GfxState *) cairo_surface_get_user_data(image, (const cairo_user_data_key_t *) 0x1);
|
|
|
c2e870 |
+ colorMap = (GfxImageColorMap *) cairo_surface_get_user_data(image, (const cairo_user_data_key_t *) 0x2);
|
|
|
c2e870 |
+ }
|
|
|
c2e870 |
|
|
|
c2e870 |
if (!printing || !(str->getKind() == strDCT || str->getKind() == strJPX))
|
|
|
c2e870 |
return;
|
|
|
c2e870 |
|
|
|
c2e870 |
+ if (state != NULL) {
|
|
|
c2e870 |
+ str->getDict()->lookup("ColorSpace", &obj);
|
|
|
c2e870 |
+ colorSpace = GfxColorSpace::parse(&obj, this, state);
|
|
|
c2e870 |
+ obj.free();
|
|
|
c2e870 |
+ }
|
|
|
c2e870 |
+
|
|
|
c2e870 |
// colorspace in stream dict may be different from colorspace in jpx
|
|
|
c2e870 |
// data
|
|
|
c2e870 |
- if (str->getKind() == strJPX) {
|
|
|
c2e870 |
- GBool hasColorSpace = !str->getDict()->lookup("ColorSpace", &obj)->isNull();
|
|
|
c2e870 |
- obj.free();
|
|
|
c2e870 |
- if (hasColorSpace)
|
|
|
c2e870 |
+ if (str->getKind() == strJPX && colorSpace)
|
|
|
c2e870 |
+ {
|
|
|
c2e870 |
+ delete colorSpace;
|
|
|
c2e870 |
return;
|
|
|
c2e870 |
+ }
|
|
|
c2e870 |
+
|
|
|
c2e870 |
+ // only embed mime data for gray, rgb, and cmyk colorspaces.
|
|
|
c2e870 |
+ if (colorSpace) {
|
|
|
c2e870 |
+ GfxColorSpaceMode mode = colorSpace->getMode();
|
|
|
c2e870 |
+ delete colorSpace;
|
|
|
c2e870 |
+ switch (mode) {
|
|
|
c2e870 |
+ case csDeviceGray:
|
|
|
c2e870 |
+ case csCalGray:
|
|
|
c2e870 |
+ case csDeviceRGB:
|
|
|
c2e870 |
+ case csCalRGB:
|
|
|
c2e870 |
+ case csDeviceCMYK:
|
|
|
c2e870 |
+ case csICCBased:
|
|
|
c2e870 |
+ break;
|
|
|
c2e870 |
+
|
|
|
c2e870 |
+ case csLab:
|
|
|
c2e870 |
+ case csIndexed:
|
|
|
c2e870 |
+ case csSeparation:
|
|
|
c2e870 |
+ case csDeviceN:
|
|
|
c2e870 |
+ case csPattern:
|
|
|
c2e870 |
+ return;
|
|
|
c2e870 |
+ }
|
|
|
c2e870 |
}
|
|
|
c2e870 |
|
|
|
c2e870 |
+ if (colorMap && !colorMapHasIdentityDecodeMap(colorMap))
|
|
|
c2e870 |
+ return;
|
|
|
c2e870 |
+
|
|
|
c2e870 |
if (getStreamData (str->getNextStream(), &strBuffer, &len)) {
|
|
|
c2e870 |
cairo_status_t st;
|
|
|
c2e870 |
|
|
|
c2e870 |
@@ -2908,8 +2960,13 @@ void CairoOutputDev::drawImage(GfxState
|
|
|
c2e870 |
if (width == widthA && height == heightA)
|
|
|
c2e870 |
filter = getFilterForSurface (image, interpolate);
|
|
|
c2e870 |
|
|
|
c2e870 |
- if (!inlineImg) /* don't read stream twice if it is an inline image */
|
|
|
c2e870 |
+ if (!inlineImg) { /* don't read stream twice if it is an inline image */
|
|
|
c2e870 |
+ cairo_surface_set_user_data(image, (const cairo_user_data_key_t *) 0x1, state, NULL);
|
|
|
c2e870 |
+ cairo_surface_set_user_data(image, (const cairo_user_data_key_t *) 0x2, colorMap, NULL);
|
|
|
c2e870 |
setMimeData(str, ref, image);
|
|
|
c2e870 |
+ cairo_surface_set_user_data(image, (const cairo_user_data_key_t *) 0x2, NULL, NULL);
|
|
|
c2e870 |
+ cairo_surface_set_user_data(image, (const cairo_user_data_key_t *) 0x1, NULL, NULL);
|
|
|
c2e870 |
+ }
|
|
|
c2e870 |
|
|
|
c2e870 |
pattern = cairo_pattern_create_for_surface (image);
|
|
|
c2e870 |
cairo_surface_destroy (image);
|