1 //========================================================================
2 //
3 // OutputDev.cc
4 //
5 // Copyright 1996-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
8
9 #include <aconf.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
setDefaultCTM(double * ctm)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
cvtDevToUser(double dx,double dy,double * ux,double * uy)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
cvtUserToDev(double ux,double uy,double * dx,double * dy)46 void OutputDev::cvtUserToDev(double ux, double uy, double *dx, double *dy) {
47 *dx = defCTM[0] * ux + defCTM[2] * uy + defCTM[4];
48 *dy = defCTM[1] * ux + defCTM[3] * uy + defCTM[5];
49 }
50
cvtUserToDev(double ux,double uy,int * dx,int * dy)51 void OutputDev::cvtUserToDev(double ux, double uy, int *dx, int *dy) {
52 *dx = (int)(defCTM[0] * ux + defCTM[2] * uy + defCTM[4] + 0.5);
53 *dy = (int)(defCTM[1] * ux + defCTM[3] * uy + defCTM[5] + 0.5);
54 }
55
updateAll(GfxState * state)56 void OutputDev::updateAll(GfxState *state) {
57 updateLineDash(state);
58 updateFlatness(state);
59 updateLineJoin(state);
60 updateLineCap(state);
61 updateMiterLimit(state);
62 updateLineWidth(state);
63 updateStrokeAdjust(state);
64 updateFillColorSpace(state);
65 updateFillColor(state);
66 updateStrokeColorSpace(state);
67 updateStrokeColor(state);
68 updateBlendMode(state);
69 updateFillOpacity(state);
70 updateStrokeOpacity(state);
71 updateFillOverprint(state);
72 updateStrokeOverprint(state);
73 updateOverprintMode(state);
74 updateTransfer(state);
75 updateFont(state);
76 }
77
beginType3Char(GfxState * state,double x,double y,double dx,double dy,CharCode code,Unicode * u,int uLen)78 GBool OutputDev::beginType3Char(GfxState *state, double x, double y,
79 double dx, double dy,
80 CharCode code, Unicode *u, int uLen) {
81 return gFalse;
82 }
83
drawImageMask(GfxState * state,Object * ref,Stream * str,int width,int height,GBool invert,GBool inlineImg,GBool interpolate)84 void OutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
85 int width, int height, GBool invert,
86 GBool inlineImg, GBool interpolate) {
87 if (inlineImg) {
88 str->reset();
89 str->discardChars(height * ((width + 7) / 8));
90 str->close();
91 }
92 }
93
setSoftMaskFromImageMask(GfxState * state,Object * ref,Stream * str,int width,int height,GBool invert,GBool inlineImg,GBool interpolate)94 void OutputDev::setSoftMaskFromImageMask(GfxState *state,
95 Object *ref, Stream *str,
96 int width, int height, GBool invert,
97 GBool inlineImg, GBool interpolate) {
98 drawImageMask(state, ref, str, width, height, invert, inlineImg, interpolate);
99 }
100
drawImage(GfxState * state,Object * ref,Stream * str,int width,int height,GfxImageColorMap * colorMap,int * maskColors,GBool inlineImg,GBool interpolate)101 void OutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
102 int width, int height, GfxImageColorMap *colorMap,
103 int *maskColors, GBool inlineImg, GBool interpolate) {
104 if (inlineImg) {
105 str->reset();
106 str->discardChars(height * ((width * colorMap->getNumPixelComps() *
107 colorMap->getBits() + 7) / 8));
108 str->close();
109 }
110 }
111
drawMaskedImage(GfxState * state,Object * ref,Stream * str,int width,int height,GfxImageColorMap * colorMap,Stream * maskStr,int maskWidth,int maskHeight,GBool maskInvert,GBool interpolate)112 void OutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
113 int width, int height,
114 GfxImageColorMap *colorMap,
115 Stream *maskStr,
116 int maskWidth, int maskHeight,
117 GBool maskInvert, GBool interpolate) {
118 drawImage(state, ref, str, width, height, colorMap, NULL, gFalse,
119 interpolate);
120 }
121
drawSoftMaskedImage(GfxState * state,Object * ref,Stream * str,int width,int height,GfxImageColorMap * colorMap,Stream * maskStr,int maskWidth,int maskHeight,GfxImageColorMap * maskColorMap,GBool interpolate)122 void OutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
123 int width, int height,
124 GfxImageColorMap *colorMap,
125 Stream *maskStr,
126 int maskWidth, int maskHeight,
127 GfxImageColorMap *maskColorMap,
128 GBool interpolate) {
129 drawImage(state, ref, str, width, height, colorMap, NULL, gFalse,
130 interpolate);
131 }
132
133 #if OPI_SUPPORT
opiBegin(GfxState * state,Dict * opiDict)134 void OutputDev::opiBegin(GfxState *state, Dict *opiDict) {
135 }
136
opiEnd(GfxState * state,Dict * opiDict)137 void OutputDev::opiEnd(GfxState *state, Dict *opiDict) {
138 }
139 #endif
140