]> git.ipfire.org Git - thirdparty/cups.git/blob - pdftops/OutputDev.cxx
Load cups into easysw/current.
[thirdparty/cups.git] / pdftops / OutputDev.cxx
1 //========================================================================
2 //
3 // OutputDev.cc
4 //
5 // Copyright 1996-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
8
9 #include <config.h>
10
11 #ifdef USE_GCC_PRAGMAS
12 #pragma implementation
13 #endif
14
15 #include <stddef.h>
16 #include "Object.h"
17 #include "Stream.h"
18 #include "GfxState.h"
19 #include "OutputDev.h"
20
21 //------------------------------------------------------------------------
22 // OutputDev
23 //------------------------------------------------------------------------
24
25 void OutputDev::setDefaultCTM(double *ctm) {
26 int i;
27 double det;
28
29 for (i = 0; i < 6; ++i) {
30 defCTM[i] = ctm[i];
31 }
32 det = 1 / (defCTM[0] * defCTM[3] - defCTM[1] * defCTM[2]);
33 defICTM[0] = defCTM[3] * det;
34 defICTM[1] = -defCTM[1] * det;
35 defICTM[2] = -defCTM[2] * det;
36 defICTM[3] = defCTM[0] * det;
37 defICTM[4] = (defCTM[2] * defCTM[5] - defCTM[3] * defCTM[4]) * det;
38 defICTM[5] = (defCTM[1] * defCTM[4] - defCTM[0] * defCTM[5]) * det;
39 }
40
41 void OutputDev::cvtDevToUser(double dx, double dy, double *ux, double *uy) {
42 *ux = defICTM[0] * dx + defICTM[2] * dy + defICTM[4];
43 *uy = defICTM[1] * dx + defICTM[3] * dy + defICTM[5];
44 }
45
46 void OutputDev::cvtUserToDev(double ux, double uy, int *dx, int *dy) {
47 *dx = (int)(defCTM[0] * ux + defCTM[2] * uy + defCTM[4] + 0.5);
48 *dy = (int)(defCTM[1] * ux + defCTM[3] * uy + defCTM[5] + 0.5);
49 }
50
51 void OutputDev::updateAll(GfxState *state) {
52 updateLineDash(state);
53 updateFlatness(state);
54 updateLineJoin(state);
55 updateLineCap(state);
56 updateMiterLimit(state);
57 updateLineWidth(state);
58 updateFillColorSpace(state);
59 updateFillColor(state);
60 updateStrokeColorSpace(state);
61 updateStrokeColor(state);
62 updateBlendMode(state);
63 updateFillOpacity(state);
64 updateStrokeOpacity(state);
65 updateFillOverprint(state);
66 updateStrokeOverprint(state);
67 updateFont(state);
68 }
69
70 GBool OutputDev::beginType3Char(GfxState *state, double x, double y,
71 double dx, double dy,
72 CharCode code, Unicode *u, int uLen) {
73 return gFalse;
74 }
75
76 void OutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
77 int width, int height, GBool invert,
78 GBool inlineImg) {
79 int i, j;
80
81 if (inlineImg) {
82 str->reset();
83 j = height * ((width + 7) / 8);
84 for (i = 0; i < j; ++i)
85 str->getChar();
86 str->close();
87 }
88 }
89
90 void OutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
91 int width, int height, GfxImageColorMap *colorMap,
92 int *maskColors, GBool inlineImg) {
93 int i, j;
94
95 if (inlineImg) {
96 str->reset();
97 j = height * ((width * colorMap->getNumPixelComps() *
98 colorMap->getBits() + 7) / 8);
99 for (i = 0; i < j; ++i)
100 str->getChar();
101 str->close();
102 }
103 }
104
105 void OutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
106 int width, int height,
107 GfxImageColorMap *colorMap,
108 Stream *maskStr,
109 int maskWidth, int maskHeight,
110 GBool maskInvert) {
111 drawImage(state, ref, str, width, height, colorMap, NULL, gFalse);
112 }
113
114 void OutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
115 int width, int height,
116 GfxImageColorMap *colorMap,
117 Stream *maskStr,
118 int maskWidth, int maskHeight,
119 GfxImageColorMap *maskColorMap) {
120 drawImage(state, ref, str, width, height, colorMap, NULL, gFalse);
121 }
122
123 #if OPI_SUPPORT
124 void OutputDev::opiBegin(GfxState *state, Dict *opiDict) {
125 }
126
127 void OutputDev::opiEnd(GfxState *state, Dict *opiDict) {
128 }
129 #endif