Rev 68 | Rev 111 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3 | paul | 1 | /*************************************************************************** |
2 | pslib.cpp - description |
||
3 | ------------------- |
||
4 | begin : Sat May 26 2001 |
||
5 | copyright : (C) 2001 by Franz Schmid |
||
6 | email : Franz.Schmid@altmuehlnet.de |
||
7 | ***************************************************************************/ |
||
8 | |||
9 | /*************************************************************************** |
||
10 | * * |
||
11 | * This program is free software; you can redistribute it and/or modify * |
||
12 | * it under the terms of the GNU General Public License as published by * |
||
13 | * the Free Software Foundation; either version 2 of the License, or * |
||
14 | * (at your option) any later version. * |
||
15 | * * |
||
16 | ***************************************************************************/ |
||
17 | #include <qfileinfo.h> |
||
18 | #include <qtextstream.h> |
||
19 | #include <qimage.h> |
||
20 | #include <qcolor.h> |
||
21 | #include <qcstring.h> |
||
22 | #include <qfontinfo.h> |
||
23 | #include <cstdlib> |
||
24 | #include <qregexp.h> |
||
25 | #include "config.h" |
||
26 | #include "pslib.h" |
||
27 | #include "scfonts.h" |
||
28 | #include <cmath> |
||
29 | |||
30 | extern bool loadText(QString nam, QString *Buffer); |
||
31 | extern QImage LoadPict(QString fn); |
||
32 | extern QString CompressStr(QString *in); |
||
33 | extern QString ImageToCMYK_PS(QImage *im, int pl, bool pre); |
||
34 | extern QString MaskToTxt(QImage *im, bool PDF = true); |
||
35 | extern char *toHex( uchar u ); |
||
36 | extern QString String2Hex(QString *in, bool lang = true); |
||
37 | #ifdef HAVE_CMS |
||
38 | extern bool CMSuse; |
||
39 | extern QImage LoadPictCol(QString fn, QString Prof, bool UseEmbedded, bool *realCMYK); |
||
40 | #endif |
||
41 | |||
42 | extern "C" void* Run(bool psart, SCFonts &AllFonts, QMap<QString,QFont> DocFonts, CListe DocColors, bool pdf); |
||
43 | |||
44 | void* Run(bool psart, SCFonts &AllFonts, QMap<QString,QFont> DocFonts, CListe DocColors, bool pdf) |
||
45 | { |
||
46 | PSLib *dia = new PSLib(psart, AllFonts, DocFonts, DocColors, pdf); |
||
47 | return dia; |
||
48 | } |
||
49 | |||
50 | PSLib::PSLib(bool psart, SCFonts &AllFonts, QMap<QString,QFont> DocFonts, CListe DocColors, bool pdf) |
||
51 | { |
||
52 | QString tmp, tmp2, tmp3, tmp4, CHset; |
||
53 | QStringList wt; |
||
54 | QString Epfad = PREL; |
||
55 | Seiten = 0; |
||
56 | User = ""; |
||
68 | Franz | 57 | Creator = "Scribus 1.0"; |
3 | paul | 58 | Titel = ""; |
59 | FillColor = "0.0 0.0 0.0 0.0"; |
||
60 | StrokeColor = "0.0 0.0 0.0 0.0"; |
||
80 | Franz | 61 | Header = psart ? "%!PS-Adobe-3.0\n" : "%!PS-Adobe-3.0 EPSF-3.0\n"; |
3 | paul | 62 | BBox = ""; |
63 | BBoxH = ""; |
||
64 | Art = psart; |
||
65 | isPDF = pdf; |
||
66 | UsedFonts.clear(); |
||
67 | Fonts = ""; |
||
68 | FontDesc = ""; |
||
69 | GraySc = false; |
||
70 | DoSep = false; |
||
71 | #ifdef HAVE_LIBZ |
||
72 | CompAvail = true; |
||
73 | #else |
||
74 | CompAvail = false; |
||
75 | #endif |
||
76 | GrayCalc = "/setcmykcolor {exch 0.11 mul add exch 0.59 mul add exch 0.3 mul add\n"; |
||
77 | GrayCalc += " dup 1 gt {pop 1} if 1 exch sub oldsetgray} bind def\n"; |
||
78 | GrayCalc += "/setrgbcolor {0.11 mul exch 0.59 mul add exch 0.3 mul add\n"; |
||
79 | GrayCalc += " oldsetgray} bind def\n"; |
||
80 | Farben = "%%CMYKCustomColor: "; |
||
81 | FNamen = "%%DocumentCustomColors: "; |
||
82 | CListe::Iterator itf; |
||
83 | int c, m, y, k; |
||
84 | bool erst = true; |
||
85 | for (itf = DocColors.begin(); itf != DocColors.end(); ++itf) |
||
86 | { |
||
87 | if ((itf.key() != "Cyan") && (itf.key() != "Magenta") && (itf.key() != "Yellow") && (itf.key() != "Black")) |
||
88 | { |
||
89 | DocColors[itf.key()].getCMYK(&c, &m, &y, &k); |
||
90 | if (!erst) |
||
91 | { |
||
92 | Farben += "%%+ "; |
||
93 | FNamen += "%%+ "; |
||
94 | } |
||
80 | Franz | 95 | Farben += ToStr(static_cast<double>(c) / 255) + " " + ToStr(static_cast<double>(m) / 255) + " "; |
96 | Farben += ToStr(static_cast<double>(y) / 255) + " " + ToStr(static_cast<double>(k) / 255) + " (" + itf.key() + ")\n"; |
||
3 | paul | 97 | FNamen += "(" + itf.key() + ")\n"; |
98 | erst = false; |
||
99 | } |
||
100 | } |
||
101 | QMap<QString,QFont>::Iterator it; |
||
102 | int a = 0; |
||
103 | for (it = DocFonts.begin(); it != DocFonts.end(); ++it) |
||
104 | { |
||
68 | Franz | 105 | if ((AllFonts[it.key()]->isOTF) || (AllFonts[it.key()]->Subset)) |
3 | paul | 106 | { |
68 | Franz | 107 | FontDesc += "/"+AllFonts[it.key()]->RealName()+" "+IToStr(AllFonts[it.key()]->RealGlyphs.count()+1)+" dict def\n"; |
108 | FontDesc += AllFonts[it.key()]->RealName()+" begin\n"; |
||
109 | QMap<uint,FPointArray>::Iterator ig; |
||
110 | for (ig = AllFonts[it.key()]->RealGlyphs.begin(); ig != AllFonts[it.key()]->RealGlyphs.end(); ++ig) |
||
111 | { |
||
112 | FontDesc += "/G"+IToStr(ig.key())+" { newpath\n"; |
||
113 | FPoint np, np1, np2; |
||
114 | bool nPath = true; |
||
115 | if (ig.data().size() > 3) |
||
116 | { |
||
117 | for (uint poi = 0; poi < ig.data().size()-3; poi += 4) |
||
118 | { |
||
119 | if (ig.data().point(poi).x() > 900000) |
||
120 | { |
||
121 | FontDesc += "cl\n"; |
||
122 | nPath = true; |
||
123 | continue; |
||
124 | } |
||
125 | if (nPath) |
||
126 | { |
||
127 | np = ig.data().point(poi); |
||
128 | FontDesc += ToStr(np.x()) + " " + ToStr(-np.y()) + " m\n"; |
||
129 | nPath = false; |
||
130 | } |
||
131 | np = ig.data().point(poi+1); |
||
132 | np1 = ig.data().point(poi+3); |
||
133 | np2 = ig.data().point(poi+2); |
||
134 | FontDesc += ToStr(np.x()) + " " + ToStr(-np.y()) + " " + ToStr(np1.x()) + " " + ToStr(-np1.y()) + " " + ToStr(np2.x()) + " " + ToStr(-np2.y()) + " cu\n"; |
||
135 | } |
||
136 | } |
||
137 | FontDesc += "cl\n} bind def\n"; |
||
138 | } |
||
139 | FontDesc += "end\n"; |
||
140 | AllFonts[it.key()]->RealGlyphs.clear(); |
||
3 | paul | 141 | } |
68 | Franz | 142 | else |
3 | paul | 143 | { |
68 | Franz | 144 | UsedFonts.insert(it.key(), "/Fo"+IToStr(a)); |
3 | paul | 145 | Fonts += "/Fo"+IToStr(a)+" /"+AllFonts[it.key()]->RealName()+" findfont definefont pop\n"; |
68 | Franz | 146 | if (AllFonts[it.key()]->EmbedPS) |
3 | paul | 147 | { |
68 | Franz | 148 | QString tmp; |
149 | if(AllFonts[it.key()]->EmbedFont(tmp)) |
||
150 | { |
||
151 | FontDesc += "%%BeginFont: " + AllFonts[it.key()]->RealName() + "\n"; |
||
152 | FontDesc += tmp + "\n%%EndFont\n"; |
||
153 | } |
||
3 | paul | 154 | } |
68 | Franz | 155 | GListe gl; |
156 | AllFonts[it.key()]->GlNames(&gl); |
||
157 | GlyphsOfFont.insert(it.key(), gl); |
||
158 | a++; |
||
3 | paul | 159 | } |
160 | } |
||
161 | Prolog = "%%BeginProlog\n"; |
||
162 | Prolog += "/Scribusdict 100 dict def\n"; |
||
163 | Prolog += "Scribusdict begin\n"; |
||
164 | Prolog += "/sp {showpage} bind def\n"; |
||
165 | Prolog += "/oldsetgray /setgray load def\n"; |
||
166 | Prolog += "/cmyk {setcmykcolor} def\n"; |
||
167 | Prolog += "/m {moveto} bind def\n"; |
||
68 | Franz | 168 | Prolog += "/l {lineto} bind def\n"; |
3 | paul | 169 | Prolog += "/li {lineto} bind def\n"; |
68 | Franz | 170 | Prolog += "/cu {curveto} bind def\n"; |
3 | paul | 171 | Prolog += "/cl {closepath} bind def\n"; |
172 | Prolog += "/gs {gsave} bind def\n"; |
||
173 | Prolog += "/gr {grestore} bind def\n"; |
||
174 | Prolog += "/tr {translate} bind def\n"; |
||
175 | Prolog += "/ro {rotate} bind def\n"; |
||
176 | Prolog += "/sh {show} bind def\n"; |
||
177 | Prolog += "/shg {setcmykcolor moveto glyphshow} def\n"; |
||
178 | Prolog += "/sc {scale} bind def\n"; |
||
179 | Prolog += "/se {selectfont} bind def\n"; |
||
180 | Prolog += "/sf {setfont} bind def\n"; |
||
181 | Prolog += "/sw {setlinewidth} bind def\n"; |
||
182 | Prolog += "/f {findfont} bind def\n"; |
||
183 | Prolog += "/fi {fill} bind def\n"; |
||
184 | Prolog += "/st {stroke} bind def\n"; |
||
68 | Franz | 185 | Prolog += "/shgf {gs dup scale begin cvx exec eofill end gr} bind def\n"; |
186 | Prolog += "/shgs {gs dup 1 exch div currentlinewidth mul sw dup scale\n"; |
||
187 | Prolog += " begin cvx exec st end gr} bind def\n"; |
||
3 | paul | 188 | Prolog += "/bEPS {\n"; |
189 | Prolog += " /b4_Inc_state save def\n"; |
||
190 | Prolog += " /dict_count countdictstack def\n"; |
||
191 | Prolog += " /op_count count 1 sub def\n"; |
||
192 | Prolog += " userdict begin\n"; |
||
193 | Prolog += " /showpage { } def\n"; |
||
194 | Prolog += " 0 setgray 0 setlinecap\n"; |
||
195 | Prolog += " 1 setlinewidth 0 setlinejoin\n"; |
||
196 | Prolog += " 10 setmiterlimit [ ] 0 setdash newpath\n"; |
||
197 | Prolog += " /languagelevel where\n"; |
||
198 | Prolog += " {pop languagelevel\n"; |
||
199 | Prolog += " 1 ne\n"; |
||
200 | Prolog += " {false setstrokeadjust false setoverprint\n"; |
||
201 | Prolog += " } if } if } bind def\n"; |
||
202 | Prolog += "/eEPS { count op_count sub {pop} repeat\n"; |
||
203 | Prolog += " countdictstack dict_count sub {end} repeat\n"; |
||
204 | Prolog += " b4_Inc_state restore } bind def\n"; |
||
205 | Prolog += " end\n"; |
||
206 | Prolog += "%%EndProlog\n"; |
||
207 | } |
||
208 | |||
209 | void PSLib::PutSeite(QString c) |
||
210 | { |
||
211 | QTextStream t(&Spool); |
||
212 | t.writeRawBytes(c, c.length()); |
||
213 | } |
||
214 | |||
215 | void PSLib::PutDoc(QString c) |
||
216 | { |
||
217 | QTextStream t(&Spool); |
||
218 | t.writeRawBytes(c, c.length()); |
||
219 | } |
||
220 | |||
80 | Franz | 221 | QString PSLib::ToStr(double c) |
3 | paul | 222 | { |
223 | QString cc; |
||
224 | return cc.setNum(c); |
||
225 | } |
||
226 | |||
227 | QString PSLib::IToStr(int c) |
||
228 | { |
||
229 | QString cc; |
||
230 | return cc.setNum(c); |
||
231 | } |
||
232 | |||
233 | void PSLib::PS_set_Info(QString art, QString was) |
||
234 | { |
||
235 | if (art == "Author") |
||
236 | User = was; |
||
237 | if (art == "Creator") |
||
238 | Creator = was; |
||
239 | if (art == "Title") |
||
240 | Titel = was; |
||
241 | } |
||
242 | |||
243 | bool PSLib::PS_set_file(QString fn) |
||
244 | { |
||
245 | Spool.setName(fn); |
||
246 | return Spool.open(IO_WriteOnly); |
||
247 | } |
||
248 | |||
80 | Franz | 249 | void PSLib::PS_begin_doc(int Ori, double breite, double hoehe, int numpage) |
3 | paul | 250 | { |
251 | PutDoc(Header); |
||
252 | PutDoc("%%For: " + User + "\n"); |
||
253 | PutDoc("%%Title: " + Titel + "\n"); |
||
254 | PutDoc("%%Creator: " + Creator + "\n"); |
||
255 | PutDoc("%%Pages: " + IToStr(numpage) + "\n"); |
||
256 | BBox = "%%BoundingBox: 0 0 " + IToStr(qRound(breite)) + " " + IToStr(qRound(hoehe)) + "\n"; |
||
257 | BBoxH = "%%HiResBoundingBox: 0 0 " + ToStr(breite) + " " + ToStr(hoehe) + "\n"; |
||
258 | if (!Art) |
||
259 | { |
||
260 | PutDoc(BBox); |
||
261 | PutDoc(BBoxH); |
||
262 | } |
||
263 | PutDoc(FNamen); |
||
264 | PutDoc(Farben); |
||
265 | PutDoc("%%LanguageLevel: 3\n"); |
||
266 | PutDoc("%%EndComments\n"); |
||
267 | PutDoc(Prolog); |
||
268 | PutDoc("%%BeginSetup\n"); |
||
269 | PutDoc("/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse\n"); |
||
270 | if (FontDesc != "") |
||
271 | { |
||
272 | PutDoc(FontDesc); |
||
273 | } |
||
274 | PutDoc("Scribusdict begin\n"); |
||
275 | PutDoc(Fonts); |
||
276 | if (GraySc) |
||
277 | PutDoc(GrayCalc); |
||
278 | PutDoc("%%EndSetup\n"); |
||
45 | Franz | 279 | /* if ((Art) && (Ori != 0)) |
3 | paul | 280 | { |
281 | PutSeite("<< /PageSize [ "+ToStr(breite)+" "+ToStr(hoehe)+" ]\n"); |
||
282 | PutSeite("/Orientation 3\n"); |
||
283 | PutSeite(">> setpagedevice\n"); |
||
45 | Franz | 284 | } */ |
3 | paul | 285 | Prolog = ""; |
286 | FontDesc = ""; |
||
287 | } |
||
288 | |||
289 | QString PSLib::PSEncode(QString in) |
||
290 | { |
||
291 | QString tmp = ""; |
||
292 | QString cc; |
||
293 | for (uint d = 0; d < in.length(); ++d) |
||
294 | { |
||
295 | cc = in.at(d); |
||
296 | if ((cc == "(") || (cc == ")") || (cc == "\\")) |
||
297 | tmp += "\\"; |
||
298 | tmp += cc; |
||
299 | } |
||
300 | tmp = tmp.simplifyWhiteSpace().replace( QRegExp("\\s"), "" ); |
||
301 | return tmp; |
||
302 | } |
||
303 | |||
80 | Franz | 304 | void PSLib::PS_TemplateStart(QString Name, double breite, double hoehe) |
3 | paul | 305 | { |
306 | PutDoc("/"+PSEncode(Name)+"\n<<\n"); |
||
307 | PutDoc("/FormType 1\n"); |
||
308 | PutDoc("/BBox [0 0 "+ToStr(breite)+" "+ToStr(hoehe)+"]\n"); |
||
309 | PutDoc("/Matrix [1 0 0 1 0 0]\n"); |
||
310 | PutDoc("/PaintProc\n{\n"); |
||
311 | } |
||
312 | |||
313 | void PSLib::PS_UseTemplate(QString Name) |
||
314 | { |
||
315 | PutDoc(PSEncode(Name)+" execform\n"); |
||
316 | } |
||
317 | |||
318 | void PSLib::PS_TemplateEnd() |
||
319 | { |
||
320 | PutDoc("pop } bind\n"); |
||
321 | PutDoc(">> def\n"); |
||
322 | } |
||
323 | |||
80 | Franz | 324 | void PSLib::PS_begin_page(double breite, double hoehe, struct Margs* Ma) |
3 | paul | 325 | { |
326 | PDev = ToStr(Ma->Left) + " " + ToStr(Ma->Bottom) + " m\n"; |
||
327 | PDev += ToStr(breite - Ma->Right) + " " + ToStr(Ma->Bottom) + " li\n"; |
||
328 | PDev += ToStr(breite - Ma->Right) + " " + ToStr(hoehe - Ma->Top) + " li\n"; |
||
329 | PDev += ToStr(Ma->Left) + " " + ToStr(hoehe - Ma->Top) + " li cl clip newpath\n"; |
||
330 | Seiten++; |
||
331 | PutSeite("%%Page: " + IToStr(Seiten) + " " + IToStr(Seiten) + "\nsave\n" + PDev); |
||
332 | PutSeite("/DeviceCMYK setcolorspace\n"); |
||
333 | } |
||
334 | |||
335 | void PSLib::PS_end_page() |
||
336 | { |
||
337 | PutSeite("%%PageTrailer\nrestore\nsp\n"); |
||
338 | } |
||
339 | |||
80 | Franz | 340 | void PSLib::PS_curve(double x1, double y1, double x2, double y2, double x3, double y3) |
3 | paul | 341 | { |
342 | PutSeite(ToStr(x1) + " " + ToStr(y1) + " " + ToStr(x2) + " " + ToStr(y2) + " " + ToStr(x3) + " " + ToStr(y3) + " curveto\n"); |
||
343 | } |
||
344 | |||
80 | Franz | 345 | void PSLib::PS_moveto(double x, double y) |
3 | paul | 346 | { |
347 | PutSeite(ToStr(x) + " " + ToStr(y) + " m\n"); |
||
348 | } |
||
349 | |||
80 | Franz | 350 | void PSLib::PS_lineto(double x, double y) |
3 | paul | 351 | { |
352 | PutSeite(ToStr(x) + " " + ToStr(y) + " li\n"); |
||
353 | } |
||
354 | |||
355 | void PSLib::PS_closepath() |
||
356 | { |
||
357 | PutSeite("cl\n"); |
||
358 | } |
||
359 | |||
80 | Franz | 360 | void PSLib::PS_translate(double x, double y) |
3 | paul | 361 | { |
362 | PutSeite(ToStr(x) + " " + ToStr(y) + " tr\n"); |
||
363 | } |
||
364 | |||
80 | Franz | 365 | void PSLib::PS_scale(double x, double y) |
3 | paul | 366 | { |
367 | PutSeite(ToStr(x) + " " + ToStr(y) + " sc\n"); |
||
368 | } |
||
369 | |||
80 | Franz | 370 | void PSLib::PS_rotate(double x) |
3 | paul | 371 | { |
372 | PutSeite(ToStr(x) + " ro\n"); |
||
373 | } |
||
374 | |||
375 | void PSLib::PS_clip(bool mu) |
||
376 | { |
||
80 | Franz | 377 | PutSeite( mu ? "eoclip newpath\n" : "clip newpath\n" ); |
3 | paul | 378 | } |
379 | |||
380 | void PSLib::PS_save() |
||
381 | { |
||
382 | PutSeite("gs\n"); |
||
383 | } |
||
384 | |||
385 | void PSLib::PS_restore() |
||
386 | { |
||
387 | PutSeite("gr\n"); |
||
388 | } |
||
389 | |||
80 | Franz | 390 | void PSLib::PS_setcmykcolor_fill(double c, double m, double y, double k) |
3 | paul | 391 | { |
392 | FillColor = ToStr(c) + " " + ToStr(m) + " " + ToStr(y) + " " + ToStr(k); |
||
393 | } |
||
394 | |||
395 | void PSLib::PS_setcmykcolor_dummy() |
||
396 | { |
||
397 | PutSeite("0 0 0 0 cmyk\n"); |
||
398 | } |
||
399 | |||
80 | Franz | 400 | void PSLib::PS_setcmykcolor_stroke(double c, double m, double y, double k) |
3 | paul | 401 | { |
402 | StrokeColor = ToStr(c) + " " + ToStr(m) + " " + ToStr(y) + " " + ToStr(k); |
||
403 | } |
||
404 | |||
80 | Franz | 405 | void PSLib::PS_setlinewidth(double w) |
3 | paul | 406 | { |
407 | PutSeite(ToStr(w) + " sw\n"); |
||
408 | LineW = w; |
||
409 | } |
||
410 | |||
411 | void PSLib::PS_setdash(Qt::PenStyle st, Qt::PenCapStyle ca, Qt::PenJoinStyle jo) |
||
412 | { |
||
413 | QString Dt = ToStr(QMAX(LineW, 1)); |
||
414 | QString Da = ToStr(QMAX(3*LineW, 1)); |
||
415 | switch (st) |
||
416 | { |
||
417 | case Qt::SolidLine: |
||
418 | PutSeite("[] 0 setdash\n"); |
||
419 | break; |
||
420 | case Qt::DashLine: |
||
421 | PutSeite("["+Da+" "+Dt+"] 0 setdash\n"); |
||
422 | break; |
||
423 | case Qt::DotLine: |
||
424 | PutSeite("["+Dt+"] 0 setdash\n"); |
||
425 | break; |
||
426 | case Qt::DashDotLine: |
||
427 | PutSeite("["+Da+" "+Dt+" "+Dt+" "+Dt+"] 0 setdash\n"); |
||
428 | break; |
||
429 | case Qt::DashDotDotLine: |
||
430 | PutSeite("["+Da+" "+Dt+" "+Dt+" "+Dt+" "+Dt+" "+Dt+"] 0 setdash\n"); |
||
431 | break; |
||
432 | default: |
||
433 | PutSeite("[] 0 setdash\n"); |
||
434 | break; |
||
435 | } |
||
436 | switch (ca) |
||
437 | { |
||
438 | case Qt::FlatCap: |
||
439 | PutSeite("0 setlinecap\n"); |
||
440 | break; |
||
441 | case Qt::SquareCap: |
||
442 | PutSeite("2 setlinecap\n"); |
||
443 | break; |
||
444 | case Qt::RoundCap: |
||
445 | PutSeite("1 setlinecap\n"); |
||
446 | break; |
||
447 | default: |
||
448 | PutSeite("0 setlinecap\n"); |
||
449 | break; |
||
450 | } |
||
451 | switch (jo) |
||
452 | { |
||
453 | case Qt::MiterJoin: |
||
454 | PutSeite("0 setlinejoin\n"); |
||
455 | break; |
||
456 | case Qt::BevelJoin: |
||
457 | PutSeite("2 setlinejoin\n"); |
||
458 | break; |
||
459 | case Qt::RoundJoin: |
||
460 | PutSeite("1 setlinejoin\n"); |
||
461 | break; |
||
462 | default: |
||
463 | PutSeite("0 setlinejoin\n"); |
||
464 | break; |
||
465 | } |
||
466 | } |
||
467 | |||
468 | void PSLib::PS_selectfont(QString f, int s) |
||
469 | { |
||
470 | PutSeite(UsedFonts[f] + " " + IToStr(s) + " se\n"); |
||
471 | } |
||
472 | |||
473 | void PSLib::PS_fill(bool mu) |
||
474 | { |
||
80 | Franz | 475 | PutSeite( mu ? FillColor + " cmyk eofill\n" : FillColor + " cmyk fi\n" ); |
3 | paul | 476 | } |
477 | |||
478 | void PSLib::PS_stroke() |
||
479 | { |
||
480 | PutSeite(StrokeColor + " cmyk st\n"); |
||
481 | } |
||
482 | |||
483 | void PSLib::PS_fill_stroke(bool mu) |
||
484 | { |
||
485 | PS_save(); |
||
486 | PS_fill(mu); |
||
487 | PS_restore(); |
||
488 | PS_stroke(); |
||
489 | } |
||
490 | |||
491 | void PSLib::PS_newpath() |
||
492 | { |
||
493 | PutSeite("newpath\n"); |
||
494 | } |
||
495 | |||
80 | Franz | 496 | void PSLib::PS_GradientCol1(double c, double m, double y, double k) |
3 | paul | 497 | { |
498 | GrColor1 = ToStr(c) + " " + ToStr(m) + " " + ToStr(y) + " " + ToStr(k); |
||
499 | } |
||
500 | |||
80 | Franz | 501 | void PSLib::PS_GradientCol2(double c, double m, double y, double k) |
3 | paul | 502 | { |
503 | GrColor2 = ToStr(c) + " " + ToStr(m) + " " + ToStr(y) + " " + ToStr(k); |
||
504 | } |
||
505 | |||
80 | Franz | 506 | void PSLib::PS_LinGradient(double w, double h, int item, int grad, bool mu) |
3 | paul | 507 | { |
508 | if (item == 1) |
||
509 | PutSeite("-"+ToStr(w / 2.0)+" "+ToStr(-h / 2.0)+" tr\n"); |
||
80 | Franz | 510 | PutSeite( mu ? "eoclip\n" : "clip\n" ); |
3 | paul | 511 | PutSeite("<<\n"); |
512 | PutSeite("/ShadingType 2\n"); |
||
80 | Franz | 513 | PutSeite( DoSep ? "/ColorSpace /DeviceGray\n" : "/ColorSpace /DeviceCMYK\n" ); |
3 | paul | 514 | switch (grad) |
515 | { |
||
516 | case 1: |
||
517 | PutSeite("/Coords [0 "+ToStr(h / 2.0)+" "+ToStr(w)+" "+ToStr(h / 2.0)+"]\n"); |
||
518 | break; |
||
519 | case 2: |
||
520 | PutSeite("/Coords ["+ToStr(w / 2.0)+" 0 "+ToStr(w / 2.0)+" "+ToStr(h)+"]\n"); |
||
521 | break; |
||
522 | case 3: |
||
523 | PutSeite("/Coords [0 0 "+ToStr(w)+" "+ToStr(h)+"]\n"); |
||
524 | break; |
||
525 | case 4: |
||
526 | PutSeite("/Coords ["+ToStr(w)+" 0 0 "+ToStr(h)+"]\n"); |
||
527 | break; |
||
528 | } |
||
529 | PutSeite("/BBox [0 "+ToStr(h)+" "+ToStr(w)+" 0]\n"); |
||
80 | Franz | 530 | PutSeite(DoSep ? QString("/Background [0]\n") : QString("/Background ["+FillColor+"]\n")); |
3 | paul | 531 | PutSeite("/Extend [false false]\n"); |
532 | PutSeite("/Function\n"); |
||
533 | PutSeite("<<\n"); |
||
534 | PutSeite("/FunctionType 2\n"); |
||
535 | PutSeite("/Domain [0 1]\n"); |
||
536 | if (DoSep) |
||
537 | { |
||
538 | int pla = Plate - 1; |
||
539 | if (pla < 0) |
||
540 | pla = 3; |
||
541 | QStringList cols1 = QStringList::split(" ", GrColor2); |
||
542 | QStringList cols2 = QStringList::split(" ", GrColor1); |
||
80 | Franz | 543 | PutSeite("/C1 ["+ToStr(1-cols1[pla].toDouble())+"]\n"); |
544 | PutSeite("/C0 ["+ToStr(1-cols2[pla].toDouble())+"]\n"); |
||
3 | paul | 545 | } |
546 | else |
||
547 | { |
||
548 | PutSeite("/C0 ["+GrColor1+"]\n"); |
||
549 | PutSeite("/C1 ["+GrColor2+"]\n"); |
||
550 | } |
||
551 | PutSeite("/N 1\n"); |
||
552 | PutSeite(">>\n"); |
||
553 | PutSeite(">>\n"); |
||
554 | PutSeite("shfill\n"); |
||
555 | } |
||
556 | |||
80 | Franz | 557 | void PSLib::PS_RadGradient(double w, double h, int item, bool mu) |
3 | paul | 558 | { |
80 | Franz | 559 | double w2, h2, rad; |
3 | paul | 560 | w2 = w / 2.0; |
561 | h2 = h / 2.0; |
||
562 | rad = QMIN(w, fabs(h)) / 2.0; |
||
563 | PutSeite("/cmtx matrix currentmatrix def\n"); |
||
80 | Franz | 564 | PutSeite( mu ? "eoclip\n" : "clip\n" ); |
3 | paul | 565 | PutSeite("<<\n"); |
566 | PutSeite("/ShadingType 3\n"); |
||
80 | Franz | 567 | PutSeite( DoSep ? "/ColorSpace /DeviceGray\n" : "/ColorSpace /DeviceCMYK\n" ); |
3 | paul | 568 | PutSeite("/Coords ["+ToStr(w2)+" "+ToStr(h2)+" 0 "+ToStr(w2)+" "+ToStr(h2)+" "+ToStr(rad)+"]\n"); |
569 | PutSeite("/BBox [0 "+ToStr(h)+" "+ToStr(w)+" 0]\n"); |
||
80 | Franz | 570 | PutSeite( DoSep ? QString("/Background [0]\n") : "/Background ["+FillColor+"]\n" ); |
3 | paul | 571 | PutSeite("/Extend [true true]\n"); |
572 | PutSeite("/Function\n"); |
||
573 | PutSeite("<<\n"); |
||
574 | PutSeite("/FunctionType 2\n"); |
||
575 | PutSeite("/Domain [0 1]\n"); |
||
576 | if (DoSep) |
||
577 | { |
||
578 | int pla = Plate - 1; |
||
579 | if (pla < 0) |
||
580 | pla = 3; |
||
581 | QStringList cols1 = QStringList::split(" ", GrColor2); |
||
582 | QStringList cols2 = QStringList::split(" ", GrColor1); |
||
80 | Franz | 583 | PutSeite("/C0 ["+ToStr(1-cols1[pla].toDouble())+"]\n"); |
584 | PutSeite("/C1 ["+ToStr(1-cols2[pla].toDouble())+"]\n"); |
||
3 | paul | 585 | } |
586 | else |
||
587 | { |
||
588 | PutSeite("/C0 ["+GrColor2+"]\n"); |
||
589 | PutSeite("/C1 ["+GrColor1+"]\n"); |
||
590 | } |
||
591 | PutSeite("/N 1\n"); |
||
592 | PutSeite(">>\n"); |
||
593 | PutSeite(">>\n"); |
||
594 | if (item == 1) |
||
80 | Franz | 595 | PutSeite( w > fabs(h) ? "-"+ToStr(w2*(w2 / rad))+" "+ToStr(fabs(h2))+" tr\n" : |
596 | "-"+ToStr(w2*(w2 / rad))+" "+ToStr(fabs(h2)*(fabs(h2) /rad))+" tr\n" ); |
||
3 | paul | 597 | else |
598 | { |
||
599 | if (w > fabs(h)) |
||
600 | PutSeite("-"+ToStr(w2*(w2 / rad)-w2)+" 0 tr\n"); |
||
601 | else |
||
602 | { |
||
603 | if (w < fabs(h)) |
||
604 | PutSeite("0 "+ToStr(fabs(h2)*(fabs(h2) /rad)-fabs(h2))+" tr\n"); |
||
605 | } |
||
606 | } |
||
607 | PutSeite(ToStr(w2 / rad)+" "+ToStr(fabs(h2) / rad)+" scale\n"); |
||
608 | PutSeite("shfill\n"); |
||
609 | PutSeite("cmtx setmatrix\n"); |
||
610 | } |
||
611 | |||
80 | Franz | 612 | void PSLib::PS_show_xyG(QString font, QString ch, double x, double y) |
3 | paul | 613 | { |
614 | QString Name; |
||
615 | uint cc = ch[0].unicode(); |
||
80 | Franz | 616 | Name = GlyphsOfFont[font].contains(cc) ? GlyphsOfFont[font][cc] : QString(".notdef"); |
3 | paul | 617 | PutSeite("/"+Name+" "+ToStr(x)+" "+ToStr(y)+" "+StrokeColor+" shg\n"); |
618 | } |
||
619 | |||
80 | Franz | 620 | void PSLib::PS_show(double x, double y) |
3 | paul | 621 | { |
622 | PS_moveto(x, y); |
||
623 | PutSeite("/hyphen glyphshow\n"); |
||
624 | } |
||
625 | |||
68 | Franz | 626 | void PSLib::PS_showSub(uint chr, QString font, int size, bool stroke) |
627 | { |
||
628 | PutSeite(FillColor + " cmyk (G"+IToStr(chr)+") "+font+" "+ToStr(size / 10.0)+" "); |
||
80 | Franz | 629 | PutSeite(stroke ? "shgs\n" : "shgf\n"); |
68 | Franz | 630 | } |
631 | |||
20 | Franz | 632 | void PSLib::PS_ImageData(bool inver, QString fn, QString Name, QString Prof, bool UseEmbedded, bool UseProf) |
3 | paul | 633 | { |
634 | QString tmp; |
||
635 | QFileInfo fi = QFileInfo(fn); |
||
636 | QString ext = fi.extension(false).lower(); |
||
637 | if (ext == "eps") |
||
638 | { |
||
639 | if (loadText(fn, &tmp)) |
||
640 | { |
||
641 | PutSeite("currentfile 1 (%ENDEPSDATA) /SubFileDecode filter /ReusableStreamDecode filter\n"); |
||
642 | PutSeite("%%BeginDocument: " + fi.fileName() + "\n"); |
||
643 | PutSeite(tmp+"\n"); |
||
644 | PutSeite("%ENDEPSDATA\n"); |
||
645 | PutSeite("%%EndDocument\n"); |
||
646 | PutSeite("/"+PSEncode(Name)+"Bild exch def\n"); |
||
647 | } |
||
648 | return; |
||
649 | } |
||
650 | QString ImgStr = ""; |
||
651 | QImage image; |
||
652 | #ifdef HAVE_CMS |
||
653 | QImage image2; |
||
654 | bool cmy = false; |
||
655 | if ((CMSuse) && (UseProf)) |
||
656 | { |
||
657 | image = LoadPict(fn); |
||
658 | image = image.convertDepth(32); |
||
659 | image2 = LoadPictCol(fn, Prof, UseEmbedded, &cmy); |
||
20 | Franz | 660 | if (inver) |
661 | { |
||
662 | image.invertPixels(); |
||
663 | image2.invertPixels(); |
||
664 | } |
||
3 | paul | 665 | ImgStr = ImageToCMYK_PS(&image2, -1, cmy); |
666 | } |
||
667 | else |
||
668 | { |
||
669 | image = LoadPict(fn); |
||
20 | Franz | 670 | if (inver) |
671 | image.invertPixels(); |
||
3 | paul | 672 | ImgStr = ImageToCMYK_PS(&image, -1, false); |
673 | } |
||
674 | #else |
||
675 | image = LoadPict(fn); |
||
676 | image = image.convertDepth(32); |
||
20 | Franz | 677 | if (inver) |
678 | image.invertPixels(); |
||
3 | paul | 679 | ImgStr = ImageToCMYK_PS(&image, -1, false); |
680 | #endif |
||
681 | if (CompAvail) |
||
682 | { |
||
683 | PutSeite("currentfile /ASCIIHexDecode filter /FlateDecode filter /ReusableStreamDecode filter\n"); |
||
684 | ImgStr = CompressStr(&ImgStr); |
||
685 | } |
||
686 | else |
||
687 | PutSeite("currentfile /ASCIIHexDecode filter /ReusableStreamDecode filter\n"); |
||
688 | ImgStr = String2Hex(&ImgStr); |
||
689 | PutSeite(ImgStr); |
||
690 | PutSeite("\n>\n"); |
||
691 | PutSeite("/"+PSEncode(Name)+"Bild exch def\n"); |
||
692 | ImgStr = ""; |
||
693 | if (image.hasAlphaBuffer()) |
||
694 | { |
||
695 | QImage iMask = image.createAlphaMask(); |
||
696 | ImgStr = MaskToTxt(&iMask, false); |
||
697 | if (CompAvail) |
||
698 | { |
||
699 | PutSeite("currentfile /ASCIIHexDecode filter /FlateDecode filter /ReusableStreamDecode filter\n"); |
||
700 | ImgStr = CompressStr(&ImgStr); |
||
701 | } |
||
702 | else |
||
703 | PutSeite("currentfile /ASCIIHexDecode filter /ReusableStreamDecode filter\n"); |
||
704 | ImgStr = String2Hex(&ImgStr); |
||
705 | PutSeite(ImgStr); |
||
706 | PutSeite("\n>\n"); |
||
707 | PutSeite("/"+PSEncode(Name)+"Mask exch def\n"); |
||
708 | } |
||
709 | } |
||
710 | |||
80 | Franz | 711 | void PSLib::PS_image(bool inver, double x, double y, QString fn, double scalex, double scaley, QString Prof, bool UseEmbedded, bool UseProf, QString Name) |
3 | paul | 712 | { |
713 | QString tmp; |
||
714 | QFileInfo fi = QFileInfo(fn); |
||
715 | QString ext = fi.extension(false).lower(); |
||
716 | if (ext == "eps") |
||
717 | { |
||
718 | if (loadText(fn, &tmp)) |
||
719 | { |
||
80 | Franz | 720 | PutSeite("bEPS\n"); |
3 | paul | 721 | PutSeite(ToStr(scalex) + " " + ToStr(scaley) + " sc\n"); |
722 | PutSeite(ToStr(x) + " " + ToStr(y) + " tr\n"); |
||
80 | Franz | 723 | if (Name != "") |
724 | { |
||
725 | PutSeite(PSEncode(Name)+"Bild cvx exec\n"); |
||
726 | PutSeite(PSEncode(Name)+"Bild resetfile\n"); |
||
727 | } |
||
728 | else |
||
729 | { |
||
730 | PutSeite("%%BeginDocument: " + fi.fileName() + "\n"); |
||
731 | PutSeite(tmp+"\n"); |
||
732 | PutSeite("%%EndDocument\n"); |
||
733 | } |
||
734 | PutSeite("eEPS\n"); |
||
3 | paul | 735 | } |
736 | } |
||
737 | else |
||
738 | { |
||
739 | QString ImgStr = ""; |
||
740 | QImage image; |
||
741 | #ifdef HAVE_CMS |
||
742 | QImage image2; |
||
743 | bool cmy = false; |
||
744 | if ((CMSuse) && (UseProf)) |
||
745 | { |
||
746 | image = LoadPict(fn); |
||
747 | image = image.convertDepth(32); |
||
748 | image2 = LoadPictCol(fn, Prof, UseEmbedded, &cmy); |
||
749 | } |
||
750 | else |
||
751 | { |
||
752 | image = LoadPict(fn); |
||
753 | image = image.convertDepth(32); |
||
754 | } |
||
20 | Franz | 755 | if (inver) |
756 | { |
||
757 | image.invertPixels(); |
||
758 | image2.invertPixels(); |
||
759 | } |
||
3 | paul | 760 | #else |
761 | image = LoadPict(fn); |
||
762 | image = image.convertDepth(32); |
||
20 | Franz | 763 | if (inver) |
764 | image.invertPixels(); |
||
3 | paul | 765 | #endif |
766 | int w = image.width(); |
||
767 | int h = image.height(); |
||
768 | PutSeite(ToStr(x*scalex) + " " + ToStr(y*scaley) + " tr\n"); |
||
769 | PutSeite(ToStr(scalex*w) + " " + ToStr(scaley*h) + " sc\n"); |
||
80 | Franz | 770 | PutSeite(((!DoSep) && (!GraySc)) ? "/DeviceCMYK setcolorspace\n" : "/DeviceGray setcolorspace\n"); |
3 | paul | 771 | if (image.hasAlphaBuffer()) |
772 | { |
||
773 | QImage iMask = image.createAlphaMask(); |
||
774 | #ifdef HAVE_CMS |
||
775 | if ((CMSuse) && (UseProf)) |
||
776 | { |
||
777 | if (DoSep) |
||
778 | ImgStr = ImageToCMYK_PS(&image2, Plate, cmy); |
||
779 | else |
||
80 | Franz | 780 | ImgStr = GraySc ? ImageToCMYK_PS(&image2, -2, cmy) : ImageToCMYK_PS(&image2, -1, cmy); |
3 | paul | 781 | } |
782 | else |
||
783 | { |
||
784 | if (DoSep) |
||
785 | ImgStr = ImageToCMYK_PS(&image, Plate, false); |
||
786 | else |
||
80 | Franz | 787 | ImgStr = GraySc ? ImageToCMYK_PS(&image, -2, false) : ImageToCMYK_PS(&image, -1, false); |
3 | paul | 788 | } |
789 | #else |
||
790 | if (DoSep) |
||
791 | ImgStr = ImageToCMYK_PS(&image, Plate, false); |
||
792 | else |
||
80 | Franz | 793 | ImgStr = GraySc ? ImageToCMYK_PS(&image, -2, false) : ImageToCMYK_PS(&image, -1, false); |
3 | paul | 794 | #endif |
795 | if (Name == "") |
||
796 | { |
||
797 | if (CompAvail) |
||
798 | { |
||
799 | PutSeite("currentfile /ASCIIHexDecode filter /FlateDecode filter /ReusableStreamDecode filter\n"); |
||
800 | ImgStr = CompressStr(&ImgStr); |
||
801 | } |
||
802 | else |
||
803 | PutSeite("currentfile /ASCIIHexDecode filter /ReusableStreamDecode filter\n"); |
||
804 | ImgStr = String2Hex(&ImgStr); |
||
805 | PutSeite(ImgStr); |
||
806 | ImgStr = ""; |
||
807 | PutSeite("\n>\n"); |
||
808 | PutSeite("/Bild exch def\n"); |
||
809 | ImgStr = MaskToTxt(&iMask, false); |
||
810 | if (CompAvail) |
||
811 | { |
||
812 | PutSeite("currentfile /ASCIIHexDecode filter /FlateDecode filter /ReusableStreamDecode filter\n"); |
||
813 | ImgStr = CompressStr(&ImgStr); |
||
814 | } |
||
815 | else |
||
816 | PutSeite("currentfile /ASCIIHexDecode filter /ReusableStreamDecode filter\n"); |
||
817 | ImgStr = String2Hex(&ImgStr); |
||
818 | PutSeite(ImgStr); |
||
819 | PutSeite("\n>\n"); |
||
820 | PutSeite("/Mask exch def\n"); |
||
821 | } |
||
822 | PutSeite("<<\n"); |
||
823 | PutSeite(" /PaintType 1\n"); |
||
824 | PutSeite(" /PatternType 1\n"); |
||
825 | PutSeite(" /TilingType 3\n"); |
||
826 | PutSeite(" /BBox [ 0 0 1 1 ]\n"); |
||
827 | PutSeite(" /XStep 2\n"); |
||
828 | PutSeite(" /YStep 2\n"); |
||
829 | PutSeite(" /PaintProc {\n"); |
||
830 | PutSeite(" pop\n"); |
||
831 | PutSeite(" 1 1 1 1 setcmykcolor\n"); |
||
832 | PutSeite(" <<\n"); |
||
833 | PutSeite(" /ImageType 1\n"); |
||
834 | PutSeite(" /Height " + IToStr(h) + "\n"); |
||
835 | PutSeite(" /Width " + IToStr(w) + "\n"); |
||
836 | PutSeite(" /ImageMatrix [" + IToStr(w) + " 0 0 " + IToStr(-h) + " 0 " + IToStr(h) +"]\n"); |
||
837 | if (DoSep) |
||
838 | PutSeite(" /Decode [1 0]\n"); |
||
839 | else |
||
80 | Franz | 840 | PutSeite( GraySc ? " /Decode [1 0]\n" : " /Decode [0 1 0 1 0 1 0 1]\n" ); |
3 | paul | 841 | PutSeite(" /BitsPerComponent 8\n"); |
842 | PutSeite(" /DataSource "+PSEncode(Name)+"Bild\n"); |
||
843 | PutSeite(" >>\n"); |
||
844 | PutSeite(" image\n"); |
||
845 | PutSeite(" }\n"); |
||
846 | PutSeite(">> matrix makepattern setpattern\n"); |
||
80 | Franz | 847 | PutSeite("<< /ImageType 1\n"); |
3 | paul | 848 | PutSeite(" /Width " + IToStr(w) + "\n"); |
849 | PutSeite(" /Height " + IToStr(h) + "\n"); |
||
850 | PutSeite(" /BitsPerComponent 1\n"); |
||
851 | PutSeite(" /Decode [1 0]\n"); |
||
852 | PutSeite(" /ImageMatrix [" + IToStr(w) + " 0 0 " + IToStr(-h) + " 0 " + IToStr(h) + "]\n"); |
||
853 | PutSeite(" /DataSource "+PSEncode(Name)+"Mask\n"); |
||
854 | PutSeite(">>\n"); |
||
855 | PutSeite("imagemask\n"); |
||
856 | if (Name != "") |
||
857 | { |
||
858 | PutSeite(PSEncode(Name)+"Bild resetfile\n"); |
||
859 | PutSeite(PSEncode(Name)+"Mask resetfile\n"); |
||
860 | } |
||
861 | } |
||
862 | else |
||
863 | { |
||
80 | Franz | 864 | PutSeite("<< /ImageType 1\n"); |
3 | paul | 865 | PutSeite(" /Width " + IToStr(w) + "\n"); |
866 | PutSeite(" /Height " + IToStr(h) + "\n"); |
||
867 | PutSeite(" /BitsPerComponent 8\n"); |
||
868 | if (DoSep) |
||
869 | PutSeite(" /Decode [1 0]\n"); |
||
870 | else |
||
80 | Franz | 871 | PutSeite( GraySc ? " /Decode [1 0]\n" : " /Decode [0 1 0 1 0 1 0 1]\n"); |
3 | paul | 872 | PutSeite(" /ImageMatrix [" + IToStr(w) + " 0 0 " + IToStr(-h) + " 0 " + IToStr(h) + "]\n"); |
873 | if (Name != "") |
||
874 | { |
||
875 | PutSeite(" /DataSource "+PSEncode(Name)+"Bild >>\n"); |
||
876 | PutSeite("image\n"); |
||
877 | PutSeite(PSEncode(Name)+"Bild resetfile\n"); |
||
878 | } |
||
879 | else |
||
80 | Franz | 880 | PutSeite ( CompAvail ? " /DataSource currentfile /ASCIIHexDecode filter /FlateDecode filter >>\n" : |
881 | " /DataSource currentfile /ASCIIHexDecode filter >>\n"); |
||
3 | paul | 882 | PutSeite("image\n"); |
883 | #ifdef HAVE_CMS |
||
884 | if ((CMSuse) && (UseProf)) |
||
885 | { |
||
886 | if (DoSep) |
||
887 | ImgStr = ImageToCMYK_PS(&image2, Plate, cmy); |
||
888 | else |
||
80 | Franz | 889 | ImgStr = GraySc ? ImageToCMYK_PS(&image2, -2, cmy) : ImageToCMYK_PS(&image2, -1, cmy); |
3 | paul | 890 | } |
891 | else |
||
892 | { |
||
893 | if (DoSep) |
||
894 | ImgStr = ImageToCMYK_PS(&image, Plate, false); |
||
895 | else |
||
80 | Franz | 896 | ImgStr = GraySc ? ImageToCMYK_PS(&image, -2, false) : ImageToCMYK_PS(&image, -1, false); |
3 | paul | 897 | } |
898 | #else |
||
899 | if (DoSep) |
||
900 | ImgStr = ImageToCMYK_PS(&image, Plate, false); |
||
901 | else |
||
80 | Franz | 902 | ImgStr = GraySc ? ImageToCMYK_PS(&image, -2, false) : ImageToCMYK_PS(&image, -1, false); |
3 | paul | 903 | #endif |
904 | if (CompAvail) |
||
905 | ImgStr = CompressStr(&ImgStr); |
||
906 | ImgStr = String2Hex(&ImgStr); |
||
907 | PutSeite(ImgStr); |
||
908 | PutSeite("\n>\n"); |
||
909 | } |
||
910 | } |
||
911 | } |
||
912 | |||
80 | Franz | 913 | |
3 | paul | 914 | void PSLib::PS_plate(int nr) |
915 | { |
||
916 | switch (nr) |
||
917 | { |
||
918 | case 0: |
||
919 | PutSeite("%%PlateColor Black\n"); |
||
920 | PutSeite("/setcmykcolor {exch pop exch pop exch pop 1 exch sub oldsetgray} bind def\n"); |
||
921 | PutSeite("/setrgbcolor {pop pop pop 1 oldsetgray} bind def\n"); |
||
922 | break; |
||
923 | case 1: |
||
924 | PutSeite("%%PlateColor Cyan\n"); |
||
925 | PutSeite("/setcmykcolor {pop pop pop 1 exch sub oldsetgray} bind def\n"); |
||
926 | PutSeite("/setrgbcolor {pop pop oldsetgray} bind def\n"); |
||
927 | break; |
||
928 | case 2: |
||
929 | PutSeite("%%PlateColor Magenta\n"); |
||
930 | PutSeite("/setcmykcolor {pop pop exch pop 1 exch sub oldsetgray} bind def\n"); |
||
931 | PutSeite("/setrgbcolor {pop exch pop oldsetgray} bind def\n"); |
||
932 | break; |
||
933 | case 3: |
||
934 | PutSeite("%%PlateColor Yellow\n"); |
||
935 | PutSeite("/setcmykcolor {pop exch pop exch pop 1 exch sub oldsetgray} bind def\n"); |
||
936 | PutSeite("/setrgbcolor {exch pop exch pop oldsetgray} bind def\n"); |
||
937 | break; |
||
938 | } |
||
939 | Plate = nr; |
||
940 | DoSep = true; |
||
941 | } |
||
942 | |||
943 | void PSLib::PS_setGray() |
||
944 | { |
||
945 | GraySc = true; |
||
946 | } |
||
947 | |||
948 | void PSLib::PDF_Bookmark(QString text, uint Seite) |
||
949 | { |
||
950 | PutSeite("[/Title ("+text+") /Page "+IToStr(Seite)+" /View [/Fit]\n"); |
||
951 | PutSeite("/OUT pdfmark\n"); |
||
952 | isPDF = true; |
||
953 | } |
||
954 | |||
80 | Franz | 955 | void PSLib::PDF_Annotation(QString text, double x, double y, double b, double h) |
3 | paul | 956 | { |
957 | PutSeite("[ /Rect [ "+ToStr(static_cast<int>(x))+" "+ToStr(static_cast<int>(y))+" "+ToStr(static_cast<int>(b))+" "+ToStr(static_cast<int>(h))+" ]\n"); |
||
958 | PutSeite(" /Contents ("+text+")\n /Open false\n"); |
||
959 | PutSeite("/ANN pdfmark\n"); |
||
960 | isPDF = true; |
||
961 | } |
||
962 | |||
963 | |||
964 | void PSLib::PS_close() |
||
965 | { |
||
966 | PutDoc("%%Trailer\n"); |
||
967 | PutDoc("end\n"); |
||
968 | PutDoc("%%EOF\n"); |
||
969 | Spool.close(); |
||
970 | } |
||
68 | Franz | 971 | |
972 | |||
973 | void PSLib::PS_insert(QString i) |
||
974 | { |
||
975 | PutDoc(i); |
||
976 | } |