6d465423b36be0e3ec29aaa7f9fc148c313c473d
[swftools.git] / pdf2swf / xpdf / OutputDev.cc
1 //========================================================================
2 //
3 // OutputDev.cc
4 //
5 // Copyright 1996-2002 Glyph & Cog, LLC
6 //
7 //========================================================================
8
9 #ifdef __GNUC__
10 #pragma implementation
11 #endif
12
13 #include <aconf.h>
14 #include <stddef.h>
15 #include "Object.h"
16 #include "Stream.h"
17 #include "GfxState.h"
18 #include "OutputDev.h"
19
20 //------------------------------------------------------------------------
21 // OutputDev
22 //------------------------------------------------------------------------
23
24 void OutputDev::setDefaultCTM(double *ctm) {
25   int i;
26   double det;
27
28   for (i = 0; i < 6; ++i) {
29     defCTM[i] = ctm[i];
30   }
31   det = 1 / (defCTM[0] * defCTM[3] - defCTM[1] * defCTM[2]);
32   defICTM[0] = defCTM[3] * det;
33   defICTM[1] = -defCTM[1] * det;
34   defICTM[2] = -defCTM[2] * det;
35   defICTM[3] = defCTM[0] * det;
36   defICTM[4] = (defCTM[2] * defCTM[5] - defCTM[3] * defCTM[4]) * det;
37   defICTM[5] = (defCTM[1] * defCTM[4] - defCTM[0] * defCTM[5]) * det;
38 }
39
40 void OutputDev::cvtDevToUser(int dx, int dy, double *ux, double *uy) {
41   *ux = defICTM[0] * dx + defICTM[2] * dy + defICTM[4];
42   *uy = defICTM[1] * dx + defICTM[3] * dy + defICTM[5];
43 }
44
45 void OutputDev::cvtUserToDev(double ux, double uy, int *dx, int *dy) {
46   *dx = (int)(defCTM[0] * ux + defCTM[2] * uy + defCTM[4] + 0.5);
47   *dy = (int)(defCTM[1] * ux + defCTM[3] * uy + defCTM[5] + 0.5);
48 }
49
50 void OutputDev::updateAll(GfxState *state) {
51   updateLineDash(state);
52   updateFlatness(state);
53   updateLineJoin(state);
54   updateLineCap(state);
55   updateMiterLimit(state);
56   updateLineWidth(state);
57   updateFillColor(state);
58   updateStrokeColor(state);
59   updateFont(state);
60 }
61
62 GBool OutputDev::beginType3Char(GfxState *state,
63                                 CharCode code, Unicode *u, int uLen) {
64   return gFalse;
65 }
66
67 void OutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
68                               int width, int height, GBool invert,
69                               GBool inlineImg) {
70   int i, j;
71
72   if (inlineImg) {
73     str->reset();
74     j = height * ((width + 7) / 8);
75     for (i = 0; i < j; ++i)
76       str->getChar();
77     str->close();
78   }
79 }
80
81 void OutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
82                           int width, int height, GfxImageColorMap *colorMap,
83                           int *maskColors, GBool inlineImg) {
84   int i, j;
85
86   if (inlineImg) {
87     str->reset();
88     j = height * ((width * colorMap->getNumPixelComps() *
89                    colorMap->getBits() + 7) / 8);
90     for (i = 0; i < j; ++i)
91       str->getChar();
92     str->close();
93   }
94 }
95
96 #if OPI_SUPPORT
97 void OutputDev::opiBegin(GfxState *state, Dict *opiDict) {
98 }
99
100 void OutputDev::opiEnd(GfxState *state, Dict *opiDict) {
101 }
102 #endif