1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
$NetBSD: patch-an,v 1.1 2009/07/28 18:22:49 drochner Exp $
--- poppler/PSOutputDev.cc.orig 2009-05-02 14:14:57.000000000 +0200
+++ poppler/PSOutputDev.cc
@@ -4565,6 +4565,8 @@ void PSOutputDev::doImageL2(Object *ref,
GfxCMYK cmyk;
int c;
int col, i, j, x0, x1, y, maskXor;
+
+ rectsOutLen = 0;
// color key masking
if (maskColors && colorMap && !inlineImg) {
@@ -4573,7 +4575,7 @@ void PSOutputDev::doImageL2(Object *ref,
numComps = colorMap->getNumPixelComps();
imgStr = new ImageStream(str, width, numComps, colorMap->getBits());
imgStr->reset();
- rects0Len = rects1Len = rectsOutLen = 0;
+ rects0Len = rects1Len = 0;
rectsSize = rectsOutSize = 64;
rects0 = (PSOutImgClipRect *)gmallocn(rectsSize, sizeof(PSOutImgClipRect));
rects1 = (PSOutImgClipRect *)gmallocn(rectsSize, sizeof(PSOutImgClipRect));
@@ -4696,14 +4698,28 @@ void PSOutputDev::doImageL2(Object *ref,
rectsOut[rectsOutLen].y1 = height - rects0[i].y0 - 1;
++rectsOutLen;
}
- writePSFmt("{0:d} array 0\n", rectsOutLen * 4);
- for (i = 0; i < rectsOutLen; ++i) {
- writePSFmt("[{0:d} {1:d} {2:d} {3:d}] pr\n",
- rectsOut[i].x0, rectsOut[i].y0,
- rectsOut[i].x1 - rectsOut[i].x0,
- rectsOut[i].y1 - rectsOut[i].y0);
+ if (rectsOutLen < 65536/4) {
+ writePSFmt("{0:d} array 0\n", rectsOutLen * 4);
+ for (i = 0; i < rectsOutLen; ++i) {
+ writePSFmt("[{0:d} {1:d} {2:d} {3:d}] pr\n",
+ rectsOut[i].x0, rectsOut[i].y0,
+ rectsOut[i].x1 - rectsOut[i].x0,
+ rectsOut[i].y1 - rectsOut[i].y0);
+ }
+ writePSFmt("pop {0:d} {1:d} pdfImClip\n", width, height);
+ } else {
+ // would be over the limit of array size.
+ // make each rectangle path and clip.
+ writePS("gsave newpath\n");
+ for (i = 0; i < rectsOutLen; ++i) {
+ writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} re\n",
+ ((double)rectsOut[i].x0)/width,
+ ((double)rectsOut[i].y0)/height,
+ ((double)(rectsOut[i].x1 - rectsOut[i].x0))/width,
+ ((double)(rectsOut[i].y1 - rectsOut[i].y0))/height);
+ }
+ writePS("clip\n");
}
- writePSFmt("pop {0:d} {1:d} pdfImClip\n", width, height);
gfree(rectsOut);
gfree(rects0);
gfree(rects1);
@@ -4798,14 +4814,28 @@ void PSOutputDev::doImageL2(Object *ref,
rectsOut[rectsOutLen].y1 = maskHeight - rects0[i].y0 - 1;
++rectsOutLen;
}
- writePSFmt("{0:d} array 0\n", rectsOutLen * 4);
- for (i = 0; i < rectsOutLen; ++i) {
- writePSFmt("[{0:d} {1:d} {2:d} {3:d}] pr\n",
- rectsOut[i].x0, rectsOut[i].y0,
- rectsOut[i].x1 - rectsOut[i].x0,
- rectsOut[i].y1 - rectsOut[i].y0);
+ if (rectsOutLen < 65536/4) {
+ writePSFmt("{0:d} array 0\n", rectsOutLen * 4);
+ for (i = 0; i < rectsOutLen; ++i) {
+ writePSFmt("[{0:d} {1:d} {2:d} {3:d}] pr\n",
+ rectsOut[i].x0, rectsOut[i].y0,
+ rectsOut[i].x1 - rectsOut[i].x0,
+ rectsOut[i].y1 - rectsOut[i].y0);
+ }
+ writePSFmt("pop {0:d} {1:d} pdfImClip\n", maskWidth, maskHeight);
+ } else {
+ // would be over the limit of array size.
+ // make each rectangle path and clip.
+ writePS("gsave newpath\n");
+ for (i = 0; i < rectsOutLen; ++i) {
+ writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} re\n",
+ ((double)rectsOut[i].x0)/maskWidth,
+ ((double)rectsOut[i].y0)/maskHeight,
+ ((double)(rectsOut[i].x1 - rectsOut[i].x0))/maskWidth,
+ ((double)(rectsOut[i].y1 - rectsOut[i].y0))/maskHeight);
+ }
+ writePS("clip\n");
}
- writePSFmt("pop {0:d} {1:d} pdfImClip\n", maskWidth, maskHeight);
gfree(rectsOut);
gfree(rects0);
gfree(rects1);
@@ -5066,7 +5096,11 @@ void PSOutputDev::doImageL2(Object *ref,
}
if ((maskColors && colorMap && !inlineImg) || maskStr) {
- writePS("pdfImClipEnd\n");
+ if (rectsOutLen < 65536/4) {
+ writePS("pdfImClipEnd\n");
+ } else {
+ writePS("grestore\n");
+ }
}
}
|