1 //========================================================================
5 // Copyright 1996-2003 Glyph & Cog, LLC
7 //========================================================================
9 //========================================================================
11 // Modified under the Poppler project - http://poppler.freedesktop.org
13 // All changes made under the Poppler project to this file are licensed
14 // under GPL version 2 or later
16 // Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com>
17 // Copyright (C) 2006 Thorkild Stray <thorkild@ifi.uio.no>
18 // Copyright (C) 2007 Adrian Johnson <ajohnson@redneon.com>
19 // Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
20 // Copyright (C) 2009, 2012, 2013 Albert Astals Cid <aacid@kde.org>
21 // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de>
23 // To see a description of the changes please see the Changelog file that
24 // came with your tarball or type make ChangeLog if you are building from git
26 //========================================================================
30 #ifdef USE_GCC_PRAGMAS
31 #pragma implementation
38 #include "OutputDev.h"
39 #include "goo/GooHash.h"
41 //------------------------------------------------------------------------
43 //------------------------------------------------------------------------
45 void OutputDev::setDefaultCTM(double *ctm
) {
49 for (i
= 0; i
< 6; ++i
) {
52 det
= 1 / (defCTM
[0] * defCTM
[3] - defCTM
[1] * defCTM
[2]);
53 defICTM
[0] = defCTM
[3] * det
;
54 defICTM
[1] = -defCTM
[1] * det
;
55 defICTM
[2] = -defCTM
[2] * det
;
56 defICTM
[3] = defCTM
[0] * det
;
57 defICTM
[4] = (defCTM
[2] * defCTM
[5] - defCTM
[3] * defCTM
[4]) * det
;
58 defICTM
[5] = (defCTM
[1] * defCTM
[4] - defCTM
[0] * defCTM
[5]) * det
;
61 void OutputDev::cvtDevToUser(double dx
, double dy
, double *ux
, double *uy
) {
62 *ux
= defICTM
[0] * dx
+ defICTM
[2] * dy
+ defICTM
[4];
63 *uy
= defICTM
[1] * dx
+ defICTM
[3] * dy
+ defICTM
[5];
66 void OutputDev::cvtUserToDev(double ux
, double uy
, int *dx
, int *dy
) {
67 *dx
= (int)(defCTM
[0] * ux
+ defCTM
[2] * uy
+ defCTM
[4] + 0.5);
68 *dy
= (int)(defCTM
[1] * ux
+ defCTM
[3] * uy
+ defCTM
[5] + 0.5);
71 void OutputDev::updateAll(GfxState
*state
) {
72 updateLineDash(state
);
73 updateFlatness(state
);
74 updateLineJoin(state
);
76 updateMiterLimit(state
);
77 updateLineWidth(state
);
78 updateStrokeAdjust(state
);
79 updateFillColorSpace(state
);
80 updateFillColor(state
);
81 updateStrokeColorSpace(state
);
82 updateStrokeColor(state
);
83 updateBlendMode(state
);
84 updateFillOpacity(state
);
85 updateStrokeOpacity(state
);
86 updateFillOverprint(state
);
87 updateStrokeOverprint(state
);
88 updateTransfer(state
);
92 GBool
OutputDev::beginType3Char(GfxState
*state
, double x
, double y
,
94 CharCode code
, Unicode
*u
, int uLen
) {
98 void OutputDev::drawImageMask(GfxState
*state
, Object
*ref
, Stream
*str
,
99 int width
, int height
, GBool invert
,
100 GBool interpolate
, GBool inlineImg
) {
105 j
= height
* ((width
+ 7) / 8);
106 for (i
= 0; i
< j
; ++i
)
112 void OutputDev::setSoftMaskFromImageMask(GfxState
*state
,
113 Object
*ref
, Stream
*str
,
114 int width
, int height
, GBool invert
,
115 GBool inlineImg
, double *baseMatrix
) {
116 drawImageMask(state
, ref
, str
, width
, height
, invert
, gFalse
, inlineImg
);
119 void OutputDev::unsetSoftMaskFromImageMask(GfxState
*state
, double *baseMatrix
) {
123 void OutputDev::drawImage(GfxState
*state
, Object
*ref
, Stream
*str
,
124 int width
, int height
, GfxImageColorMap
*colorMap
,
125 GBool interpolate
, int *maskColors
, GBool inlineImg
) {
130 j
= height
* ((width
* colorMap
->getNumPixelComps() *
131 colorMap
->getBits() + 7) / 8);
132 for (i
= 0; i
< j
; ++i
)
138 void OutputDev::drawMaskedImage(GfxState
*state
, Object
*ref
, Stream
*str
,
139 int width
, int height
,
140 GfxImageColorMap
*colorMap
,
143 int maskWidth
, int maskHeight
,
145 GBool maskInterpolate
) {
146 drawImage(state
, ref
, str
, width
, height
, colorMap
, interpolate
, NULL
, gFalse
);
149 void OutputDev::drawSoftMaskedImage(GfxState
*state
, Object
*ref
, Stream
*str
,
150 int width
, int height
,
151 GfxImageColorMap
*colorMap
,
154 int maskWidth
, int maskHeight
,
155 GfxImageColorMap
*maskColorMap
,
156 GBool maskInterpolate
) {
157 drawImage(state
, ref
, str
, width
, height
, colorMap
, interpolate
, NULL
, gFalse
);
160 void OutputDev::endMarkedContent(GfxState
*state
) {
163 void OutputDev::beginMarkedContent(char *name
, Dict
*properties
) {
166 void OutputDev::markPoint(char *name
) {
169 void OutputDev::markPoint(char *name
, Dict
*properties
) {
174 void OutputDev::opiBegin(GfxState
*state
, Dict
*opiDict
) {
177 void OutputDev::opiEnd(GfxState
*state
, Dict
*opiDict
) {
181 void OutputDev::startProfile() {
185 profileHash
= new GooHash (true);
188 GooHash
*OutputDev::endProfile() {
189 GooHash
*profile
= profileHash
;
197 PopplerCache
*OutputDev::getIccColorSpaceCache()
199 return &iccColorSpaceCache
;