node-poppler 5.1.4 → 5.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/package.json +10 -10
  3. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Annot.h +0 -1783
  4. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/AnnotStampImageHelper.h +0 -68
  5. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Array.h +0 -92
  6. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/BBoxOutputDev.h +0 -54
  7. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/CMap.h +0 -128
  8. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/CachedFile.h +0 -149
  9. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/CairoFontEngine.h +0 -122
  10. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/CairoOutputDev.h +0 -468
  11. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/CairoRescaleBox.h +0 -60
  12. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Catalog.h +0 -318
  13. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/CertificateInfo.h +0 -129
  14. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/CharCodeToUnicode.h +0 -143
  15. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/CharTypes.h +0 -24
  16. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/CurlCachedFile.h +0 -37
  17. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/CurlPDFDocBuilder.h +0 -32
  18. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/DateInfo.h +0 -44
  19. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Decrypt.h +0 -147
  20. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Dict.h +0 -126
  21. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Error.h +0 -59
  22. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/ErrorCodes.h +0 -54
  23. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/FDPDFDocBuilder.h +0 -36
  24. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/FILECacheLoader.h +0 -34
  25. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/FileSpec.h +0 -85
  26. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/FontEncodingTables.h +0 -20
  27. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/FontInfo.h +0 -109
  28. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Form.h +0 -734
  29. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Function.h +0 -251
  30. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Gfx.h +0 -373
  31. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/GfxFont.h +0 -466
  32. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/GfxState.h +0 -1759
  33. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/GfxState_helpers.h +0 -90
  34. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/GlobalParams.h +0 -221
  35. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Hints.h +0 -91
  36. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/JArithmeticDecoder.h +0 -131
  37. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/JBIG2Stream.h +0 -130
  38. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/JPEG2000Stream.h +0 -54
  39. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/JSInfo.h +0 -65
  40. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Lexer.h +0 -113
  41. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Linearization.h +0 -43
  42. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Link.h +0 -566
  43. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/LocalPDFDocBuilder.h +0 -32
  44. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/MarkedContentOutputDev.h +0 -132
  45. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Movie.h +0 -123
  46. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/NameToCharCode.h +0 -52
  47. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/NameToUnicodeTable.h +0 -4300
  48. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Object.h +0 -678
  49. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/OptionalContent.h +0 -117
  50. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Outline.h +0 -122
  51. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/OutputDev.h +0 -379
  52. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/PDFDoc.h +0 -419
  53. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/PDFDocBuilder.h +0 -47
  54. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/PDFDocEncoding.h +0 -43
  55. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/PDFDocFactory.h +0 -58
  56. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/PSOutputDev.h +0 -549
  57. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/PSTokenizer.h +0 -47
  58. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Page.h +0 -273
  59. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/PageTransition.h +0 -105
  60. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Parser.h +0 -76
  61. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/PopplerCache.h +0 -65
  62. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/PreScanOutputDev.h +0 -148
  63. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/ProfileData.h +0 -35
  64. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Rendition.h +0 -164
  65. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/SecurityHandler.h +0 -131
  66. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Sound.h +0 -82
  67. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/SplashOutputDev.h +0 -413
  68. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Stream-CCITT.h +0 -334
  69. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/Stream.h +0 -1504
  70. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/StructElement.h +0 -406
  71. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/StructTreeRoot.h +0 -89
  72. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/TextOutputDev.h +0 -918
  73. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/UTF.h +0 -112
  74. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/UnicodeCClassTables.h +0 -983
  75. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/UnicodeCompTables.h +0 -328
  76. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/UnicodeDecompTables.h +0 -7181
  77. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/UnicodeMap.h +0 -128
  78. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/UnicodeMapFuncs.h +0 -35
  79. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/UnicodeMapTables.h +0 -84
  80. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/UnicodeTypeTable.h +0 -49
  81. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/ViewerPreferences.h +0 -87
  82. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/XRef.h +0 -325
  83. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/cpp/poppler-destination.h +0 -69
  84. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/cpp/poppler-document.h +0 -135
  85. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/cpp/poppler-embedded-file.h +0 -55
  86. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/cpp/poppler-font-private.h +0 -68
  87. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/cpp/poppler-font.h +0 -95
  88. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/cpp/poppler-global.h +0 -132
  89. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/cpp/poppler-image.h +0 -74
  90. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/cpp/poppler-page-renderer.h +0 -77
  91. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/cpp/poppler-page-transition.h +0 -85
  92. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/cpp/poppler-page.h +0 -225
  93. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/cpp/poppler-rectangle.h +0 -66
  94. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/cpp/poppler-toc.h +0 -72
  95. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/cpp/poppler-version.h +0 -39
  96. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/cpp/poppler_cpp_export.h +0 -42
  97. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/fofi/FoFiBase.h +0 -66
  98. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/fofi/FoFiEncodings.h +0 -43
  99. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/fofi/FoFiIdentifier.h +0 -52
  100. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/fofi/FoFiTrueType.h +0 -190
  101. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/fofi/FoFiType1.h +0 -70
  102. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/fofi/FoFiType1C.h +0 -263
  103. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/glib/poppler-action.h +0 -454
  104. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/glib/poppler-annot.h +0 -333
  105. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/glib/poppler-attachment.h +0 -123
  106. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/glib/poppler-date.h +0 -32
  107. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/glib/poppler-document.h +0 -541
  108. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/glib/poppler-enums.h +0 -191
  109. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/glib/poppler-features.h +0 -88
  110. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/glib/poppler-form-field.h +0 -254
  111. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/glib/poppler-layer.h +0 -50
  112. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/glib/poppler-macros.h +0 -42
  113. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/glib/poppler-media.h +0 -80
  114. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/glib/poppler-movie.h +0 -81
  115. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/glib/poppler-page.h +0 -424
  116. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/glib/poppler-structure-element.h +0 -425
  117. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/glib/poppler.h +0 -259
  118. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/goo/GooCheckedOps.h +0 -116
  119. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/goo/GooLikely.h +0 -22
  120. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/goo/GooString.h +0 -262
  121. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/goo/GooTimer.h +0 -59
  122. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/goo/ImgWriter.h +0 -39
  123. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/goo/JpegWriter.h +0 -69
  124. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/goo/PNGWriter.h +0 -68
  125. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/goo/TiffWriter.h +0 -70
  126. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/goo/gdir.h +0 -96
  127. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/goo/gfile.h +0 -156
  128. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/goo/gmem.h +0 -201
  129. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/goo/grandom.h +0 -21
  130. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/goo/gstrtod.h +0 -45
  131. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/poppler-config.h +0 -155
  132. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/poppler_private_export.h +0 -42
  133. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/Splash.h +0 -336
  134. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashBitmap.h +0 -127
  135. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashClip.h +0 -131
  136. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashErrorCodes.h +0 -50
  137. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashFTFont.h +0 -71
  138. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashFTFontEngine.h +0 -72
  139. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashFTFontFile.h +0 -64
  140. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashFont.h +0 -116
  141. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashFontEngine.h +0 -89
  142. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashFontFile.h +0 -98
  143. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashFontFileID.h +0 -40
  144. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashGlyphBitmap.h +0 -23
  145. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashMath.h +0 -215
  146. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashPath.h +0 -138
  147. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashPattern.h +0 -107
  148. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashScreen.h +0 -87
  149. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashState.h +0 -132
  150. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashTypes.h +0 -248
  151. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashXPath.h +0 -95
  152. package/src/lib/win32/poppler-22.04.0/Library/include/poppler/splash/SplashXPathScanner.h +0 -136
  153. package/src/lib/win32/poppler-22.04.0/Library/lib/pkgconfig/poppler-cpp.pc +0 -12
  154. package/src/lib/win32/poppler-22.04.0/Library/lib/pkgconfig/poppler-glib.pc +0 -12
  155. package/src/lib/win32/poppler-22.04.0/Library/lib/pkgconfig/poppler.pc +0 -10
  156. package/src/lib/win32/poppler-22.04.0/Library/lib/poppler-cpp.lib +0 -0
  157. package/src/lib/win32/poppler-22.04.0/Library/lib/poppler-glib.lib +0 -0
  158. package/src/lib/win32/poppler-22.04.0/Library/lib/poppler.lib +0 -0
  159. package/src/lib/win32/poppler-22.04.0/Library/share/man/man1/pdfattach.1 +0 -60
  160. package/src/lib/win32/poppler-22.04.0/Library/share/man/man1/pdfdetach.1 +0 -94
  161. package/src/lib/win32/poppler-22.04.0/Library/share/man/man1/pdffonts.1 +0 -128
  162. package/src/lib/win32/poppler-22.04.0/Library/share/man/man1/pdfimages.1 +0 -265
  163. package/src/lib/win32/poppler-22.04.0/Library/share/man/man1/pdfinfo.1 +0 -198
  164. package/src/lib/win32/poppler-22.04.0/Library/share/man/man1/pdfseparate.1 +0 -60
  165. package/src/lib/win32/poppler-22.04.0/Library/share/man/man1/pdftocairo.1 +0 -346
  166. package/src/lib/win32/poppler-22.04.0/Library/share/man/man1/pdftohtml.1 +0 -118
  167. package/src/lib/win32/poppler-22.04.0/Library/share/man/man1/pdftoppm.1 +0 -230
  168. package/src/lib/win32/poppler-22.04.0/Library/share/man/man1/pdftops.1 +0 -267
  169. package/src/lib/win32/poppler-22.04.0/Library/share/man/man1/pdftotext.1 +0 -157
  170. package/src/lib/win32/poppler-22.04.0/Library/share/man/man1/pdfunite.1 +0 -43
  171. package/src/lib/win32/poppler-22.04.0/share/poppler/CMakeLists.txt +0 -309
  172. package/src/lib/win32/poppler-22.04.0/share/poppler/Makefile +0 -333
@@ -1,1759 +0,0 @@
1
- //========================================================================
2
- //
3
- // GfxState.h
4
- //
5
- // Copyright 1996-2003 Glyph & Cog, LLC
6
- //
7
- //========================================================================
8
-
9
- //========================================================================
10
- //
11
- // Modified under the Poppler project - http://poppler.freedesktop.org
12
- //
13
- // All changes made under the Poppler project to this file are licensed
14
- // under GPL version 2 or later
15
- //
16
- // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
17
- // Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net>
18
- // Copyright (C) 2006 Carlos Garcia Campos <carlosgc@gnome.org>
19
- // Copyright (C) 2009 Koji Otani <sho@bbr.jp>
20
- // Copyright (C) 2009-2011, 2013, 2016-2021 Albert Astals Cid <aacid@kde.org>
21
- // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com>
22
- // Copyright (C) 2011 Andrea Canciani <ranma42@gmail.com>
23
- // Copyright (C) 2011-2014, 2016, 2020 Thomas Freitag <Thomas.Freitag@alfa.de>
24
- // Copyright (C) 2013 Lu Wang <coolwanglu@gmail.com>
25
- // Copyright (C) 2015, 2017, 2020 Adrian Johnson <ajohnson@redneon.com>
26
- // Copyright (C) 2017, 2019, 2022 Oliver Sander <oliver.sander@tu-dresden.de>
27
- // Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>
28
- // Copyright (C) 2020, 2021 Philipp Knechtges <philipp-dev@knechtges.com>
29
- //
30
- // To see a description of the changes please see the Changelog file that
31
- // came with your tarball or type make ChangeLog if you are building from git
32
- //
33
- //========================================================================
34
-
35
- #ifndef GFXSTATE_H
36
- #define GFXSTATE_H
37
-
38
- #include "poppler-config.h"
39
- #include "poppler_private_export.h"
40
-
41
- #include "Object.h"
42
- #include "Function.h"
43
-
44
- #include <cassert>
45
- #include <map>
46
- #include <memory>
47
-
48
- class Array;
49
- class Gfx;
50
- class GfxFont;
51
- class PDFRectangle;
52
- class GfxShading;
53
- class OutputDev;
54
- class GfxState;
55
- class GfxResources;
56
- class GfxSeparationColorSpace;
57
-
58
- class Matrix
59
- {
60
- public:
61
- double m[6];
62
-
63
- void init(double xx, double yx, double xy, double yy, double x0, double y0)
64
- {
65
- m[0] = xx;
66
- m[1] = yx;
67
- m[2] = xy;
68
- m[3] = yy;
69
- m[4] = x0;
70
- m[5] = y0;
71
- }
72
- bool invertTo(Matrix *other) const;
73
- void translate(double tx, double ty);
74
- void scale(double sx, double sy);
75
- void transform(double x, double y, double *tx, double *ty) const;
76
- double determinant() const { return m[0] * m[3] - m[1] * m[2]; }
77
- double norm() const;
78
- };
79
-
80
- //------------------------------------------------------------------------
81
- // GfxBlendMode
82
- //------------------------------------------------------------------------
83
-
84
- enum GfxBlendMode
85
- {
86
- gfxBlendNormal,
87
- gfxBlendMultiply,
88
- gfxBlendScreen,
89
- gfxBlendOverlay,
90
- gfxBlendDarken,
91
- gfxBlendLighten,
92
- gfxBlendColorDodge,
93
- gfxBlendColorBurn,
94
- gfxBlendHardLight,
95
- gfxBlendSoftLight,
96
- gfxBlendDifference,
97
- gfxBlendExclusion,
98
- gfxBlendHue,
99
- gfxBlendSaturation,
100
- gfxBlendColor,
101
- gfxBlendLuminosity
102
- };
103
-
104
- //------------------------------------------------------------------------
105
- // GfxColorComp
106
- //------------------------------------------------------------------------
107
-
108
- // 16.16 fixed point color component
109
- typedef int GfxColorComp;
110
-
111
- #define gfxColorComp1 0x10000
112
-
113
- static inline GfxColorComp dblToCol(double x)
114
- {
115
- return (GfxColorComp)(x * gfxColorComp1);
116
- }
117
-
118
- static inline double colToDbl(GfxColorComp x)
119
- {
120
- return (double)x / (double)gfxColorComp1;
121
- }
122
-
123
- static inline unsigned char dblToByte(double x)
124
- {
125
- return (x * 255.0);
126
- }
127
-
128
- static inline double byteToDbl(unsigned char x)
129
- {
130
- return (double)x / (double)255.0;
131
- }
132
-
133
- static inline GfxColorComp byteToCol(unsigned char x)
134
- {
135
- // (x / 255) << 16 = (0.0000000100000001... * x) << 16
136
- // = ((x << 8) + (x) + (x >> 8) + ...) << 16
137
- // = (x << 8) + (x) + (x >> 7)
138
- // [for rounding]
139
- return (GfxColorComp)((x << 8) + x + (x >> 7));
140
- }
141
-
142
- static inline unsigned char colToByte(GfxColorComp x)
143
- {
144
- // 255 * x + 0.5 = 256 * x - x + 0x8000
145
- return (unsigned char)(((x << 8) - x + 0x8000) >> 16);
146
- }
147
-
148
- static inline unsigned short colToShort(GfxColorComp x)
149
- {
150
- return (unsigned short)(x);
151
- }
152
-
153
- //------------------------------------------------------------------------
154
- // GfxColor
155
- //------------------------------------------------------------------------
156
-
157
- #define gfxColorMaxComps funcMaxOutputs
158
-
159
- struct GfxColor
160
- {
161
- GfxColorComp c[gfxColorMaxComps];
162
- };
163
-
164
- static inline void clearGfxColor(GfxColor *gfxColor)
165
- {
166
- memset(gfxColor->c, 0, sizeof(GfxColorComp) * gfxColorMaxComps);
167
- }
168
-
169
- //------------------------------------------------------------------------
170
- // GfxGray
171
- //------------------------------------------------------------------------
172
-
173
- typedef GfxColorComp GfxGray;
174
-
175
- //------------------------------------------------------------------------
176
- // GfxRGB
177
- //------------------------------------------------------------------------
178
-
179
- struct GfxRGB
180
- {
181
- GfxColorComp r, g, b;
182
- };
183
-
184
- //------------------------------------------------------------------------
185
- // GfxCMYK
186
- //------------------------------------------------------------------------
187
-
188
- struct GfxCMYK
189
- {
190
- GfxColorComp c, m, y, k;
191
- };
192
-
193
- //------------------------------------------------------------------------
194
- // GfxColorSpace
195
- //------------------------------------------------------------------------
196
-
197
- // NB: The nGfxColorSpaceModes constant and the gfxColorSpaceModeNames
198
- // array defined in GfxState.cc must match this enum.
199
- enum GfxColorSpaceMode
200
- {
201
- csDeviceGray,
202
- csCalGray,
203
- csDeviceRGB,
204
- csCalRGB,
205
- csDeviceCMYK,
206
- csLab,
207
- csICCBased,
208
- csIndexed,
209
- csSeparation,
210
- csDeviceN,
211
- csPattern
212
- };
213
-
214
- // This shall hold a cmsHPROFILE handle.
215
- // Only use the make_GfxLCMSProfilePtr function to construct this pointer,
216
- // to ensure that the resources are properly released after usage.
217
- typedef std::shared_ptr<void> GfxLCMSProfilePtr;
218
-
219
- #ifdef USE_CMS
220
- GfxLCMSProfilePtr POPPLER_PRIVATE_EXPORT make_GfxLCMSProfilePtr(void *profile);
221
- #endif
222
-
223
- // wrapper of cmsHTRANSFORM to copy
224
- class GfxColorTransform
225
- {
226
- public:
227
- void doTransform(void *in, void *out, unsigned int size);
228
- // transformA should be a cmsHTRANSFORM
229
- GfxColorTransform(void *transformA, int cmsIntent, unsigned int inputPixelType, unsigned int transformPixelType);
230
- ~GfxColorTransform();
231
- GfxColorTransform(const GfxColorTransform &) = delete;
232
- GfxColorTransform &operator=(const GfxColorTransform &) = delete;
233
- int getIntent() const { return cmsIntent; }
234
- int getInputPixelType() const { return inputPixelType; }
235
- int getTransformPixelType() const { return transformPixelType; }
236
-
237
- private:
238
- GfxColorTransform() { }
239
- void *transform;
240
- int cmsIntent;
241
- unsigned int inputPixelType;
242
- unsigned int transformPixelType;
243
- };
244
-
245
- class POPPLER_PRIVATE_EXPORT GfxColorSpace
246
- {
247
- public:
248
- GfxColorSpace();
249
- virtual ~GfxColorSpace();
250
-
251
- GfxColorSpace(const GfxColorSpace &) = delete;
252
- GfxColorSpace &operator=(const GfxColorSpace &other) = delete;
253
-
254
- virtual GfxColorSpace *copy() const = 0;
255
- virtual GfxColorSpaceMode getMode() const = 0;
256
-
257
- // Construct a color space. Returns nullptr if unsuccessful.
258
- static GfxColorSpace *parse(GfxResources *res, Object *csObj, OutputDev *out, GfxState *state, int recursion = 0);
259
-
260
- // Convert to gray, RGB, or CMYK.
261
- virtual void getGray(const GfxColor *color, GfxGray *gray) const = 0;
262
- virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const = 0;
263
- virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const = 0;
264
- virtual void getDeviceN(const GfxColor *color, GfxColor *deviceN) const = 0;
265
- virtual void getGrayLine(unsigned char * /*in*/, unsigned char * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getGrayLine this should not happen"); }
266
- virtual void getRGBLine(unsigned char * /*in*/, unsigned int * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getRGBLine (first variant) this should not happen"); }
267
- virtual void getRGBLine(unsigned char * /*in*/, unsigned char * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getRGBLine (second variant) this should not happen"); }
268
- virtual void getRGBXLine(unsigned char * /*in*/, unsigned char * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getRGBXLine this should not happen"); }
269
- virtual void getCMYKLine(unsigned char * /*in*/, unsigned char * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getCMYKLine this should not happen"); }
270
- virtual void getDeviceNLine(unsigned char * /*in*/, unsigned char * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getDeviceNLine this should not happen"); }
271
-
272
- // create mapping for spot colorants
273
- virtual void createMapping(std::vector<GfxSeparationColorSpace *> *separationList, int maxSepComps);
274
- int *getMapping() const { return mapping; }
275
-
276
- // Does this ColorSpace support getRGBLine?
277
- virtual bool useGetRGBLine() const { return false; }
278
- // Does this ColorSpace support getGrayLine?
279
- virtual bool useGetGrayLine() const { return false; }
280
- // Does this ColorSpace support getCMYKLine?
281
- virtual bool useGetCMYKLine() const { return false; }
282
- // Does this ColorSpace support getDeviceNLine?
283
- virtual bool useGetDeviceNLine() const { return false; }
284
-
285
- // Return the number of color components.
286
- virtual int getNComps() const = 0;
287
-
288
- // Get this color space's default color.
289
- virtual void getDefaultColor(GfxColor *color) const = 0;
290
-
291
- // Return the default ranges for each component, assuming an image
292
- // with a max pixel value of <maxImgPixel>.
293
- virtual void getDefaultRanges(double *decodeLow, double *decodeRange, int maxImgPixel) const;
294
-
295
- // Returns true if painting operations in this color space never
296
- // mark the page (e.g., the "None" colorant).
297
- virtual bool isNonMarking() const { return false; }
298
-
299
- // Return the color space's overprint mask.
300
- unsigned int getOverprintMask() const { return overprintMask; }
301
-
302
- // Return the number of color space modes
303
- static int getNumColorSpaceModes();
304
-
305
- // Return the name of the <idx>th color space mode.
306
- static const char *getColorSpaceModeName(int idx);
307
-
308
- protected:
309
- unsigned int overprintMask;
310
- int *mapping;
311
- };
312
-
313
- //------------------------------------------------------------------------
314
- // GfxDeviceGrayColorSpace
315
- //------------------------------------------------------------------------
316
-
317
- class POPPLER_PRIVATE_EXPORT GfxDeviceGrayColorSpace : public GfxColorSpace
318
- {
319
- public:
320
- GfxDeviceGrayColorSpace();
321
- ~GfxDeviceGrayColorSpace() override;
322
- GfxColorSpace *copy() const override;
323
- GfxColorSpaceMode getMode() const override { return csDeviceGray; }
324
-
325
- void getGray(const GfxColor *color, GfxGray *gray) const override;
326
- void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
327
- void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
328
- void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
329
- void getGrayLine(unsigned char *in, unsigned char *out, int length) override;
330
- void getRGBLine(unsigned char *in, unsigned int *out, int length) override;
331
- void getRGBLine(unsigned char *in, unsigned char *out, int length) override;
332
- void getRGBXLine(unsigned char *in, unsigned char *out, int length) override;
333
- void getCMYKLine(unsigned char *in, unsigned char *out, int length) override;
334
- void getDeviceNLine(unsigned char *in, unsigned char *out, int length) override;
335
-
336
- bool useGetRGBLine() const override { return true; }
337
- bool useGetGrayLine() const override { return true; }
338
- bool useGetCMYKLine() const override { return true; }
339
- bool useGetDeviceNLine() const override { return true; }
340
-
341
- int getNComps() const override { return 1; }
342
- void getDefaultColor(GfxColor *color) const override;
343
-
344
- private:
345
- };
346
-
347
- //------------------------------------------------------------------------
348
- // GfxCalGrayColorSpace
349
- //------------------------------------------------------------------------
350
-
351
- class GfxCalGrayColorSpace : public GfxColorSpace
352
- {
353
- public:
354
- GfxCalGrayColorSpace();
355
- ~GfxCalGrayColorSpace() override;
356
- GfxColorSpace *copy() const override;
357
- GfxColorSpaceMode getMode() const override { return csCalGray; }
358
-
359
- // Construct a CalGray color space. Returns nullptr if unsuccessful.
360
- static GfxColorSpace *parse(Array *arr, GfxState *state);
361
-
362
- void getGray(const GfxColor *color, GfxGray *gray) const override;
363
- void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
364
- void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
365
- void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
366
-
367
- int getNComps() const override { return 1; }
368
- void getDefaultColor(GfxColor *color) const override;
369
-
370
- // CalGray-specific access.
371
- double getWhiteX() const { return whiteX; }
372
- double getWhiteY() const { return whiteY; }
373
- double getWhiteZ() const { return whiteZ; }
374
- double getBlackX() const { return blackX; }
375
- double getBlackY() const { return blackY; }
376
- double getBlackZ() const { return blackZ; }
377
- double getGamma() const { return gamma; }
378
-
379
- private:
380
- double whiteX, whiteY, whiteZ; // white point
381
- double blackX, blackY, blackZ; // black point
382
- double gamma; // gamma value
383
- void getXYZ(const GfxColor *color, double *pX, double *pY, double *pZ) const;
384
- #ifdef USE_CMS
385
- std::shared_ptr<GfxColorTransform> transform;
386
- #endif
387
- };
388
-
389
- //------------------------------------------------------------------------
390
- // GfxDeviceRGBColorSpace
391
- //------------------------------------------------------------------------
392
-
393
- class POPPLER_PRIVATE_EXPORT GfxDeviceRGBColorSpace : public GfxColorSpace
394
- {
395
- public:
396
- GfxDeviceRGBColorSpace();
397
- ~GfxDeviceRGBColorSpace() override;
398
- GfxColorSpace *copy() const override;
399
- GfxColorSpaceMode getMode() const override { return csDeviceRGB; }
400
-
401
- void getGray(const GfxColor *color, GfxGray *gray) const override;
402
- void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
403
- void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
404
- void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
405
- void getGrayLine(unsigned char *in, unsigned char *out, int length) override;
406
- void getRGBLine(unsigned char *in, unsigned int *out, int length) override;
407
- void getRGBLine(unsigned char *in, unsigned char *out, int length) override;
408
- void getRGBXLine(unsigned char *in, unsigned char *out, int length) override;
409
- void getCMYKLine(unsigned char *in, unsigned char *out, int length) override;
410
- void getDeviceNLine(unsigned char *in, unsigned char *out, int length) override;
411
-
412
- bool useGetRGBLine() const override { return true; }
413
- bool useGetGrayLine() const override { return true; }
414
- bool useGetCMYKLine() const override { return true; }
415
- bool useGetDeviceNLine() const override { return true; }
416
-
417
- int getNComps() const override { return 3; }
418
- void getDefaultColor(GfxColor *color) const override;
419
-
420
- private:
421
- };
422
-
423
- //------------------------------------------------------------------------
424
- // GfxCalRGBColorSpace
425
- //------------------------------------------------------------------------
426
-
427
- class GfxCalRGBColorSpace : public GfxColorSpace
428
- {
429
- public:
430
- GfxCalRGBColorSpace();
431
- ~GfxCalRGBColorSpace() override;
432
- GfxColorSpace *copy() const override;
433
- GfxColorSpaceMode getMode() const override { return csCalRGB; }
434
-
435
- // Construct a CalRGB color space. Returns nullptr if unsuccessful.
436
- static GfxColorSpace *parse(Array *arr, GfxState *state);
437
-
438
- void getGray(const GfxColor *color, GfxGray *gray) const override;
439
- void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
440
- void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
441
- void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
442
-
443
- int getNComps() const override { return 3; }
444
- void getDefaultColor(GfxColor *color) const override;
445
-
446
- // CalRGB-specific access.
447
- double getWhiteX() const { return whiteX; }
448
- double getWhiteY() const { return whiteY; }
449
- double getWhiteZ() const { return whiteZ; }
450
- double getBlackX() const { return blackX; }
451
- double getBlackY() const { return blackY; }
452
- double getBlackZ() const { return blackZ; }
453
- double getGammaR() const { return gammaR; }
454
- double getGammaG() const { return gammaG; }
455
- double getGammaB() const { return gammaB; }
456
- const double *getMatrix() const { return mat; }
457
-
458
- private:
459
- double whiteX, whiteY, whiteZ; // white point
460
- double blackX, blackY, blackZ; // black point
461
- double gammaR, gammaG, gammaB; // gamma values
462
- double mat[9]; // ABC -> XYZ transform matrix
463
- void getXYZ(const GfxColor *color, double *pX, double *pY, double *pZ) const;
464
- #ifdef USE_CMS
465
- std::shared_ptr<GfxColorTransform> transform;
466
- #endif
467
- };
468
-
469
- //------------------------------------------------------------------------
470
- // GfxDeviceCMYKColorSpace
471
- //------------------------------------------------------------------------
472
-
473
- class POPPLER_PRIVATE_EXPORT GfxDeviceCMYKColorSpace : public GfxColorSpace
474
- {
475
- public:
476
- GfxDeviceCMYKColorSpace();
477
- ~GfxDeviceCMYKColorSpace() override;
478
- GfxColorSpace *copy() const override;
479
- GfxColorSpaceMode getMode() const override { return csDeviceCMYK; }
480
-
481
- void getGray(const GfxColor *color, GfxGray *gray) const override;
482
- void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
483
- void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
484
- void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
485
- void getRGBLine(unsigned char *in, unsigned int *out, int length) override;
486
- void getRGBLine(unsigned char *, unsigned char *out, int length) override;
487
- void getRGBXLine(unsigned char *in, unsigned char *out, int length) override;
488
- void getCMYKLine(unsigned char *in, unsigned char *out, int length) override;
489
- void getDeviceNLine(unsigned char *in, unsigned char *out, int length) override;
490
- bool useGetRGBLine() const override { return true; }
491
- bool useGetCMYKLine() const override { return true; }
492
- bool useGetDeviceNLine() const override { return true; }
493
-
494
- int getNComps() const override { return 4; }
495
- void getDefaultColor(GfxColor *color) const override;
496
-
497
- private:
498
- };
499
-
500
- //------------------------------------------------------------------------
501
- // GfxLabColorSpace
502
- //------------------------------------------------------------------------
503
-
504
- class GfxLabColorSpace : public GfxColorSpace
505
- {
506
- public:
507
- GfxLabColorSpace();
508
- ~GfxLabColorSpace() override;
509
- GfxColorSpace *copy() const override;
510
- GfxColorSpaceMode getMode() const override { return csLab; }
511
-
512
- // Construct a Lab color space. Returns nullptr if unsuccessful.
513
- static GfxColorSpace *parse(Array *arr, GfxState *state);
514
-
515
- void getGray(const GfxColor *color, GfxGray *gray) const override;
516
- void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
517
- void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
518
- void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
519
-
520
- int getNComps() const override { return 3; }
521
- void getDefaultColor(GfxColor *color) const override;
522
-
523
- void getDefaultRanges(double *decodeLow, double *decodeRange, int maxImgPixel) const override;
524
-
525
- // Lab-specific access.
526
- double getWhiteX() const { return whiteX; }
527
- double getWhiteY() const { return whiteY; }
528
- double getWhiteZ() const { return whiteZ; }
529
- double getBlackX() const { return blackX; }
530
- double getBlackY() const { return blackY; }
531
- double getBlackZ() const { return blackZ; }
532
- double getAMin() const { return aMin; }
533
- double getAMax() const { return aMax; }
534
- double getBMin() const { return bMin; }
535
- double getBMax() const { return bMax; }
536
-
537
- private:
538
- double whiteX, whiteY, whiteZ; // white point
539
- double blackX, blackY, blackZ; // black point
540
- double aMin, aMax, bMin, bMax; // range for the a and b components
541
- void getXYZ(const GfxColor *color, double *pX, double *pY, double *pZ) const;
542
- #ifdef USE_CMS
543
- std::shared_ptr<GfxColorTransform> transform;
544
- #endif
545
- };
546
-
547
- //------------------------------------------------------------------------
548
- // GfxICCBasedColorSpace
549
- //------------------------------------------------------------------------
550
-
551
- class POPPLER_PRIVATE_EXPORT GfxICCBasedColorSpace : public GfxColorSpace
552
- {
553
- public:
554
- GfxICCBasedColorSpace(int nCompsA, GfxColorSpace *altA, const Ref *iccProfileStreamA);
555
- ~GfxICCBasedColorSpace() override;
556
- GfxColorSpace *copy() const override;
557
- GfxColorSpaceMode getMode() const override { return csICCBased; }
558
-
559
- // Construct an ICCBased color space. Returns nullptr if unsuccessful.
560
- static GfxColorSpace *parse(Array *arr, OutputDev *out, GfxState *state, int recursion);
561
-
562
- void getGray(const GfxColor *color, GfxGray *gray) const override;
563
- void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
564
- void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
565
- void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
566
- void getRGBLine(unsigned char *in, unsigned int *out, int length) override;
567
- void getRGBLine(unsigned char *in, unsigned char *out, int length) override;
568
- void getRGBXLine(unsigned char *in, unsigned char *out, int length) override;
569
- void getCMYKLine(unsigned char *in, unsigned char *out, int length) override;
570
- void getDeviceNLine(unsigned char *in, unsigned char *out, int length) override;
571
-
572
- bool useGetRGBLine() const override;
573
- bool useGetCMYKLine() const override;
574
- bool useGetDeviceNLine() const override;
575
-
576
- int getNComps() const override { return nComps; }
577
- void getDefaultColor(GfxColor *color) const override;
578
-
579
- void getDefaultRanges(double *decodeLow, double *decodeRange, int maxImgPixel) const override;
580
-
581
- // ICCBased-specific access.
582
- GfxColorSpace *getAlt() { return alt; }
583
- Ref getRef() { return iccProfileStream; }
584
- #ifdef USE_CMS
585
- char *getPostScriptCSA();
586
- void buildTransforms(GfxState *state);
587
- void setProfile(GfxLCMSProfilePtr &profileA) { profile = profileA; }
588
- GfxLCMSProfilePtr getProfile() { return profile; }
589
- #endif
590
-
591
- private:
592
- int nComps; // number of color components (1, 3, or 4)
593
- GfxColorSpace *alt; // alternate color space
594
- double rangeMin[4]; // min values for each component
595
- double rangeMax[4]; // max values for each component
596
- Ref iccProfileStream; // the ICC profile
597
- #ifdef USE_CMS
598
- GfxLCMSProfilePtr profile;
599
- char *psCSA;
600
- int getIntent() { return (transform != nullptr) ? transform->getIntent() : 0; }
601
- std::shared_ptr<GfxColorTransform> transform;
602
- std::shared_ptr<GfxColorTransform> lineTransform; // color transform for line
603
- mutable std::map<unsigned int, unsigned int> cmsCache;
604
- #endif
605
- };
606
- //------------------------------------------------------------------------
607
- // GfxIndexedColorSpace
608
- //------------------------------------------------------------------------
609
-
610
- class GfxIndexedColorSpace : public GfxColorSpace
611
- {
612
- public:
613
- GfxIndexedColorSpace(GfxColorSpace *baseA, int indexHighA);
614
- ~GfxIndexedColorSpace() override;
615
- GfxColorSpace *copy() const override;
616
- GfxColorSpaceMode getMode() const override { return csIndexed; }
617
-
618
- // Construct an Indexed color space. Returns nullptr if unsuccessful.
619
- static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
620
-
621
- void getGray(const GfxColor *color, GfxGray *gray) const override;
622
- void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
623
- void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
624
- void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
625
- void getRGBLine(unsigned char *in, unsigned int *out, int length) override;
626
- void getRGBLine(unsigned char *in, unsigned char *out, int length) override;
627
- void getRGBXLine(unsigned char *in, unsigned char *out, int length) override;
628
- void getCMYKLine(unsigned char *in, unsigned char *out, int length) override;
629
- void getDeviceNLine(unsigned char *in, unsigned char *out, int length) override;
630
-
631
- bool useGetRGBLine() const override { return true; }
632
- bool useGetCMYKLine() const override { return true; }
633
- bool useGetDeviceNLine() const override { return true; }
634
-
635
- int getNComps() const override { return 1; }
636
- void getDefaultColor(GfxColor *color) const override;
637
-
638
- void getDefaultRanges(double *decodeLow, double *decodeRange, int maxImgPixel) const override;
639
-
640
- // Indexed-specific access.
641
- GfxColorSpace *getBase() { return base; }
642
- int getIndexHigh() const { return indexHigh; }
643
- unsigned char *getLookup() { return lookup; }
644
- GfxColor *mapColorToBase(const GfxColor *color, GfxColor *baseColor) const;
645
- unsigned int getOverprintMask() const { return base->getOverprintMask(); }
646
- void createMapping(std::vector<GfxSeparationColorSpace *> *separationList, int maxSepComps) override { base->createMapping(separationList, maxSepComps); }
647
-
648
- private:
649
- GfxColorSpace *base; // base color space
650
- int indexHigh; // max pixel value
651
- unsigned char *lookup; // lookup table
652
- };
653
-
654
- //------------------------------------------------------------------------
655
- // GfxSeparationColorSpace
656
- //------------------------------------------------------------------------
657
-
658
- class GfxSeparationColorSpace : public GfxColorSpace
659
- {
660
- public:
661
- GfxSeparationColorSpace(GooString *nameA, GfxColorSpace *altA, Function *funcA);
662
- ~GfxSeparationColorSpace() override;
663
- GfxColorSpace *copy() const override;
664
- GfxColorSpaceMode getMode() const override { return csSeparation; }
665
-
666
- // Construct a Separation color space. Returns nullptr if unsuccessful.
667
- static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
668
-
669
- void getGray(const GfxColor *color, GfxGray *gray) const override;
670
- void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
671
- void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
672
- void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
673
-
674
- void createMapping(std::vector<GfxSeparationColorSpace *> *separationList, int maxSepComps) override;
675
-
676
- int getNComps() const override { return 1; }
677
- void getDefaultColor(GfxColor *color) const override;
678
-
679
- bool isNonMarking() const override { return nonMarking; }
680
-
681
- // Separation-specific access.
682
- const GooString *getName() const { return name; }
683
- GfxColorSpace *getAlt() { return alt; }
684
- const Function *getFunc() const { return func; }
685
-
686
- private:
687
- GfxSeparationColorSpace(GooString *nameA, GfxColorSpace *altA, Function *funcA, bool nonMarkingA, unsigned int overprintMaskA, int *mappingA);
688
-
689
- GooString *name; // colorant name
690
- GfxColorSpace *alt; // alternate color space
691
- Function *func; // tint transform (into alternate color space)
692
- bool nonMarking;
693
- };
694
-
695
- //------------------------------------------------------------------------
696
- // GfxDeviceNColorSpace
697
- //------------------------------------------------------------------------
698
-
699
- class GfxDeviceNColorSpace : public GfxColorSpace
700
- {
701
- public:
702
- GfxDeviceNColorSpace(int nCompsA, std::vector<std::string> &&namesA, GfxColorSpace *alt, Function *func, std::vector<GfxSeparationColorSpace *> *sepsCS);
703
- ~GfxDeviceNColorSpace() override;
704
- GfxColorSpace *copy() const override;
705
- GfxColorSpaceMode getMode() const override { return csDeviceN; }
706
-
707
- // Construct a DeviceN color space. Returns nullptr if unsuccessful.
708
- static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
709
-
710
- void getGray(const GfxColor *color, GfxGray *gray) const override;
711
- void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
712
- void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
713
- void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
714
-
715
- void createMapping(std::vector<GfxSeparationColorSpace *> *separationList, int maxSepComps) override;
716
-
717
- int getNComps() const override { return nComps; }
718
- void getDefaultColor(GfxColor *color) const override;
719
-
720
- bool isNonMarking() const override { return nonMarking; }
721
-
722
- // DeviceN-specific access.
723
- const std::string &getColorantName(int i) const { return names[i]; }
724
- GfxColorSpace *getAlt() { return alt; }
725
- const Function *getTintTransformFunc() const { return func; }
726
-
727
- private:
728
- GfxDeviceNColorSpace(int nCompsA, const std::vector<std::string> &namesA, GfxColorSpace *alt, Function *func, std::vector<GfxSeparationColorSpace *> *sepsCSA, int *mappingA, bool nonMarkingA, unsigned int overprintMaskA);
729
-
730
- const int nComps; // number of components
731
- const std::vector<std::string> names; // colorant names
732
- GfxColorSpace *alt; // alternate color space
733
- Function *func; // tint transform (into alternate color space)
734
- bool nonMarking;
735
- std::vector<GfxSeparationColorSpace *> *sepsCS; // list of separation cs for spot colorants;
736
- };
737
-
738
- //------------------------------------------------------------------------
739
- // GfxPatternColorSpace
740
- //------------------------------------------------------------------------
741
-
742
- class GfxPatternColorSpace : public GfxColorSpace
743
- {
744
- public:
745
- explicit GfxPatternColorSpace(GfxColorSpace *underA);
746
- ~GfxPatternColorSpace() override;
747
- GfxColorSpace *copy() const override;
748
- GfxColorSpaceMode getMode() const override { return csPattern; }
749
-
750
- // Construct a Pattern color space. Returns nullptr if unsuccessful.
751
- static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
752
-
753
- void getGray(const GfxColor *color, GfxGray *gray) const override;
754
- void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
755
- void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
756
- void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
757
-
758
- int getNComps() const override { return 0; }
759
- void getDefaultColor(GfxColor *color) const override;
760
-
761
- // Pattern-specific access.
762
- GfxColorSpace *getUnder() { return under; }
763
-
764
- private:
765
- GfxColorSpace *under; // underlying color space (for uncolored
766
- // patterns)
767
- };
768
-
769
- //------------------------------------------------------------------------
770
- // GfxPattern
771
- //------------------------------------------------------------------------
772
-
773
- class GfxPattern
774
- {
775
- public:
776
- GfxPattern(int typeA, int patternRefNumA);
777
- virtual ~GfxPattern();
778
-
779
- GfxPattern(const GfxPattern &) = delete;
780
- GfxPattern &operator=(const GfxPattern &other) = delete;
781
-
782
- static GfxPattern *parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state, int patternRefNum);
783
-
784
- virtual GfxPattern *copy() const = 0;
785
-
786
- int getType() const { return type; }
787
-
788
- int getPatternRefNum() const { return patternRefNum; }
789
-
790
- private:
791
- int type;
792
- int patternRefNum;
793
- };
794
-
795
- //------------------------------------------------------------------------
796
- // GfxTilingPattern
797
- //------------------------------------------------------------------------
798
-
799
- class GfxTilingPattern : public GfxPattern
800
- {
801
- public:
802
- static GfxTilingPattern *parse(Object *patObj, int patternRefNum);
803
- ~GfxTilingPattern() override;
804
-
805
- GfxPattern *copy() const override;
806
-
807
- int getPaintType() const { return paintType; }
808
- int getTilingType() const { return tilingType; }
809
- const double *getBBox() const { return bbox; }
810
- double getXStep() const { return xStep; }
811
- double getYStep() const { return yStep; }
812
- Dict *getResDict() { return resDict.isDict() ? resDict.getDict() : (Dict *)nullptr; }
813
- const double *getMatrix() const { return matrix; }
814
- Object *getContentStream() { return &contentStream; }
815
-
816
- private:
817
- GfxTilingPattern(int paintTypeA, int tilingTypeA, const double *bboxA, double xStepA, double yStepA, const Object *resDictA, const double *matrixA, const Object *contentStreamA, int patternRefNumA);
818
-
819
- int paintType;
820
- int tilingType;
821
- double bbox[4];
822
- double xStep, yStep;
823
- Object resDict;
824
- double matrix[6];
825
- Object contentStream;
826
- };
827
-
828
- //------------------------------------------------------------------------
829
- // GfxShadingPattern
830
- //------------------------------------------------------------------------
831
-
832
- class GfxShadingPattern : public GfxPattern
833
- {
834
- public:
835
- static GfxShadingPattern *parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state, int patternRefNum);
836
- ~GfxShadingPattern() override;
837
-
838
- GfxPattern *copy() const override;
839
-
840
- GfxShading *getShading() { return shading; }
841
- const double *getMatrix() const { return matrix; }
842
-
843
- private:
844
- GfxShadingPattern(GfxShading *shadingA, const double *matrixA, int patternRefNumA);
845
-
846
- GfxShading *shading;
847
- double matrix[6];
848
- };
849
-
850
- //------------------------------------------------------------------------
851
- // GfxShading
852
- //------------------------------------------------------------------------
853
-
854
- class GfxShading
855
- {
856
- public:
857
- explicit GfxShading(int typeA);
858
- explicit GfxShading(const GfxShading *shading);
859
- virtual ~GfxShading();
860
-
861
- GfxShading(const GfxShading &) = delete;
862
- GfxShading &operator=(const GfxShading &other) = delete;
863
-
864
- static GfxShading *parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state);
865
-
866
- virtual GfxShading *copy() const = 0;
867
-
868
- int getType() const { return type; }
869
- GfxColorSpace *getColorSpace() { return colorSpace; }
870
- const GfxColor *getBackground() const { return &background; }
871
- bool getHasBackground() const { return hasBackground; }
872
- void getBBox(double *xMinA, double *yMinA, double *xMaxA, double *yMaxA) const
873
- {
874
- *xMinA = bbox_xMin;
875
- *yMinA = bbox_yMin;
876
- *xMaxA = bbox_xMax;
877
- *yMaxA = bbox_yMax;
878
- }
879
- bool getHasBBox() const { return hasBBox; }
880
-
881
- protected:
882
- virtual bool init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
883
-
884
- // 1: Function-based shading
885
- // 2: Axial shading
886
- // 3: Radial shading
887
- // 4: Free-form Gouraud-shaded triangle mesh
888
- // 5: Lattice-form Gouraud-shaded triangle mesh
889
- // 6: Coons patch mesh
890
- // 7: Tensor-product patch mesh
891
- int type;
892
- bool hasBackground;
893
- bool hasBBox;
894
- GfxColorSpace *colorSpace;
895
- GfxColor background;
896
- double bbox_xMin, bbox_yMin, bbox_xMax, bbox_yMax;
897
- };
898
-
899
- //------------------------------------------------------------------------
900
- // GfxUnivariateShading
901
- //------------------------------------------------------------------------
902
-
903
- class POPPLER_PRIVATE_EXPORT GfxUnivariateShading : public GfxShading
904
- {
905
- public:
906
- GfxUnivariateShading(int typeA, double t0A, double t1A, std::vector<std::unique_ptr<Function>> &&funcsA, bool extend0A, bool extend1A);
907
- explicit GfxUnivariateShading(const GfxUnivariateShading *shading);
908
- ~GfxUnivariateShading() override;
909
-
910
- double getDomain0() const { return t0; }
911
- double getDomain1() const { return t1; }
912
- bool getExtend0() const { return extend0; }
913
- bool getExtend1() const { return extend1; }
914
- int getNFuncs() const { return funcs.size(); }
915
- const Function *getFunc(int i) const { return funcs[i].get(); }
916
- // returns the nComps of the shading
917
- // i.e. how many positions of color have been set
918
- int getColor(double t, GfxColor *color);
919
-
920
- void setupCache(const Matrix *ctm, double xMin, double yMin, double xMax, double yMax);
921
-
922
- virtual void getParameterRange(double *lower, double *upper, double xMin, double yMin, double xMax, double yMax) = 0;
923
-
924
- virtual double getDistance(double sMin, double sMax) const = 0;
925
-
926
- protected:
927
- bool init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) override;
928
-
929
- private:
930
- double t0, t1;
931
- std::vector<std::unique_ptr<Function>> funcs;
932
- bool extend0, extend1;
933
-
934
- int cacheSize, lastMatch;
935
- double *cacheBounds;
936
- double *cacheCoeff;
937
- double *cacheValues;
938
- };
939
-
940
- //------------------------------------------------------------------------
941
- // GfxFunctionShading
942
- //------------------------------------------------------------------------
943
-
944
- class POPPLER_PRIVATE_EXPORT GfxFunctionShading : public GfxShading
945
- {
946
- public:
947
- GfxFunctionShading(double x0A, double y0A, double x1A, double y1A, const double *matrixA, std::vector<std::unique_ptr<Function>> &&funcsA);
948
- explicit GfxFunctionShading(const GfxFunctionShading *shading);
949
- ~GfxFunctionShading() override;
950
-
951
- static GfxFunctionShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
952
-
953
- GfxShading *copy() const override;
954
-
955
- void getDomain(double *x0A, double *y0A, double *x1A, double *y1A) const
956
- {
957
- *x0A = x0;
958
- *y0A = y0;
959
- *x1A = x1;
960
- *y1A = y1;
961
- }
962
- const double *getMatrix() const { return matrix; }
963
- int getNFuncs() const { return funcs.size(); }
964
- const Function *getFunc(int i) const { return funcs[i].get(); }
965
- void getColor(double x, double y, GfxColor *color) const;
966
-
967
- protected:
968
- bool init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) override;
969
-
970
- private:
971
- double x0, y0, x1, y1;
972
- double matrix[6];
973
- std::vector<std::unique_ptr<Function>> funcs;
974
- };
975
-
976
- //------------------------------------------------------------------------
977
- // GfxAxialShading
978
- //------------------------------------------------------------------------
979
-
980
- class GfxAxialShading : public GfxUnivariateShading
981
- {
982
- public:
983
- GfxAxialShading(double x0A, double y0A, double x1A, double y1A, double t0A, double t1A, std::vector<std::unique_ptr<Function>> &&funcsA, bool extend0A, bool extend1A);
984
- explicit GfxAxialShading(const GfxAxialShading *shading);
985
- ~GfxAxialShading() override;
986
-
987
- static GfxAxialShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
988
-
989
- GfxShading *copy() const override;
990
-
991
- void getCoords(double *x0A, double *y0A, double *x1A, double *y1A) const
992
- {
993
- *x0A = x0;
994
- *y0A = y0;
995
- *x1A = x1;
996
- *y1A = y1;
997
- }
998
-
999
- void getParameterRange(double *lower, double *upper, double xMin, double yMin, double xMax, double yMax) override;
1000
-
1001
- double getDistance(double sMin, double sMax) const override;
1002
-
1003
- private:
1004
- double x0, y0, x1, y1;
1005
- };
1006
-
1007
- //------------------------------------------------------------------------
1008
- // GfxRadialShading
1009
- //------------------------------------------------------------------------
1010
-
1011
- class GfxRadialShading : public GfxUnivariateShading
1012
- {
1013
- public:
1014
- GfxRadialShading(double x0A, double y0A, double r0A, double x1A, double y1A, double r1A, double t0A, double t1A, std::vector<std::unique_ptr<Function>> &&funcsA, bool extend0A, bool extend1A);
1015
- explicit GfxRadialShading(const GfxRadialShading *shading);
1016
- ~GfxRadialShading() override;
1017
-
1018
- static GfxRadialShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
1019
-
1020
- GfxShading *copy() const override;
1021
-
1022
- void getCoords(double *x0A, double *y0A, double *r0A, double *x1A, double *y1A, double *r1A) const
1023
- {
1024
- *x0A = x0;
1025
- *y0A = y0;
1026
- *r0A = r0;
1027
- *x1A = x1;
1028
- *y1A = y1;
1029
- *r1A = r1;
1030
- }
1031
-
1032
- void getParameterRange(double *lower, double *upper, double xMin, double yMin, double xMax, double yMax) override;
1033
-
1034
- double getDistance(double sMin, double sMax) const override;
1035
-
1036
- private:
1037
- double x0, y0, r0, x1, y1, r1;
1038
- };
1039
-
1040
- //------------------------------------------------------------------------
1041
- // GfxGouraudTriangleShading
1042
- //------------------------------------------------------------------------
1043
-
1044
- struct GfxGouraudVertex
1045
- {
1046
- double x, y;
1047
- GfxColor color;
1048
- };
1049
-
1050
- class POPPLER_PRIVATE_EXPORT GfxGouraudTriangleShading : public GfxShading
1051
- {
1052
- public:
1053
- GfxGouraudTriangleShading(int typeA, GfxGouraudVertex *verticesA, int nVerticesA, int (*trianglesA)[3], int nTrianglesA, std::vector<std::unique_ptr<Function>> &&funcsA);
1054
- explicit GfxGouraudTriangleShading(const GfxGouraudTriangleShading *shading);
1055
- ~GfxGouraudTriangleShading() override;
1056
-
1057
- static GfxGouraudTriangleShading *parse(GfxResources *res, int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state);
1058
-
1059
- GfxShading *copy() const override;
1060
-
1061
- int getNTriangles() const { return nTriangles; }
1062
-
1063
- bool isParameterized() const { return !funcs.empty(); }
1064
-
1065
- /**
1066
- * @precondition isParameterized() == true
1067
- */
1068
- double getParameterDomainMin() const
1069
- {
1070
- assert(isParameterized());
1071
- return funcs[0]->getDomainMin(0);
1072
- }
1073
-
1074
- /**
1075
- * @precondition isParameterized() == true
1076
- */
1077
- double getParameterDomainMax() const
1078
- {
1079
- assert(isParameterized());
1080
- return funcs[0]->getDomainMax(0);
1081
- }
1082
-
1083
- /**
1084
- * @precondition isParameterized() == false
1085
- */
1086
- void getTriangle(int i, double *x0, double *y0, GfxColor *color0, double *x1, double *y1, GfxColor *color1, double *x2, double *y2, GfxColor *color2);
1087
-
1088
- /**
1089
- * Variant for functions.
1090
- *
1091
- * @precondition isParameterized() == true
1092
- */
1093
- void getTriangle(int i, double *x0, double *y0, double *color0, double *x1, double *y1, double *color1, double *x2, double *y2, double *color2);
1094
-
1095
- void getParameterizedColor(double t, GfxColor *color) const;
1096
-
1097
- protected:
1098
- bool init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) override;
1099
-
1100
- private:
1101
- GfxGouraudVertex *vertices;
1102
- int nVertices;
1103
- int (*triangles)[3];
1104
- int nTriangles;
1105
- std::vector<std::unique_ptr<Function>> funcs;
1106
- };
1107
-
1108
- //------------------------------------------------------------------------
1109
- // GfxPatchMeshShading
1110
- //------------------------------------------------------------------------
1111
-
1112
- /**
1113
- * A tensor product cubic bezier patch consisting of 4x4 points and 4 color
1114
- * values.
1115
- *
1116
- * See the Shading Type 7 specifications. Note that Shading Type 6 is also
1117
- * represented using GfxPatch.
1118
- */
1119
- struct GfxPatch
1120
- {
1121
- /**
1122
- * Represents a single color value for the patch.
1123
- */
1124
- struct ColorValue
1125
- {
1126
- /**
1127
- * For parameterized patches, only element 0 is valid; it contains
1128
- * the single parameter.
1129
- *
1130
- * For non-parameterized patches, c contains all color components
1131
- * as decoded from the input stream. In this case, you will need to
1132
- * use dblToCol() before assigning them to GfxColor.
1133
- */
1134
- double c[gfxColorMaxComps];
1135
- };
1136
-
1137
- double x[4][4];
1138
- double y[4][4];
1139
- ColorValue color[2][2];
1140
- };
1141
-
1142
- class POPPLER_PRIVATE_EXPORT GfxPatchMeshShading : public GfxShading
1143
- {
1144
- public:
1145
- GfxPatchMeshShading(int typeA, GfxPatch *patchesA, int nPatchesA, std::vector<std::unique_ptr<Function>> &&funcsA);
1146
- explicit GfxPatchMeshShading(const GfxPatchMeshShading *shading);
1147
- ~GfxPatchMeshShading() override;
1148
-
1149
- static GfxPatchMeshShading *parse(GfxResources *res, int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state);
1150
-
1151
- GfxShading *copy() const override;
1152
-
1153
- int getNPatches() const { return nPatches; }
1154
- const GfxPatch *getPatch(int i) const { return &patches[i]; }
1155
-
1156
- bool isParameterized() const { return !funcs.empty(); }
1157
-
1158
- /**
1159
- * @precondition isParameterized() == true
1160
- */
1161
- double getParameterDomainMin() const
1162
- {
1163
- assert(isParameterized());
1164
- return funcs[0]->getDomainMin(0);
1165
- }
1166
-
1167
- /**
1168
- * @precondition isParameterized() == true
1169
- */
1170
- double getParameterDomainMax() const
1171
- {
1172
- assert(isParameterized());
1173
- return funcs[0]->getDomainMax(0);
1174
- }
1175
-
1176
- void getParameterizedColor(double t, GfxColor *color) const;
1177
-
1178
- protected:
1179
- bool init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) override;
1180
-
1181
- private:
1182
- GfxPatch *patches;
1183
- int nPatches;
1184
- std::vector<std::unique_ptr<Function>> funcs;
1185
- };
1186
-
1187
- //------------------------------------------------------------------------
1188
- // GfxImageColorMap
1189
- //------------------------------------------------------------------------
1190
-
1191
- class POPPLER_PRIVATE_EXPORT GfxImageColorMap
1192
- {
1193
- public:
1194
- // Constructor.
1195
- GfxImageColorMap(int bitsA, Object *decode, GfxColorSpace *colorSpaceA);
1196
-
1197
- // Destructor.
1198
- ~GfxImageColorMap();
1199
-
1200
- GfxImageColorMap(const GfxImageColorMap &) = delete;
1201
- GfxImageColorMap &operator=(const GfxImageColorMap &) = delete;
1202
-
1203
- // Return a copy of this color map.
1204
- GfxImageColorMap *copy() const { return new GfxImageColorMap(this); }
1205
-
1206
- // Is color map valid?
1207
- bool isOk() const { return ok; }
1208
-
1209
- // Get the color space.
1210
- GfxColorSpace *getColorSpace() { return colorSpace; }
1211
-
1212
- // Get stream decoding info.
1213
- int getNumPixelComps() const { return nComps; }
1214
- int getBits() const { return bits; }
1215
-
1216
- // Get decode table.
1217
- double getDecodeLow(int i) const { return decodeLow[i]; }
1218
- double getDecodeHigh(int i) const { return decodeLow[i] + decodeRange[i]; }
1219
-
1220
- bool useRGBLine() const { return (colorSpace2 && colorSpace2->useGetRGBLine()) || (!colorSpace2 && colorSpace->useGetRGBLine()); }
1221
- bool useCMYKLine() const { return (colorSpace2 && colorSpace2->useGetCMYKLine()) || (!colorSpace2 && colorSpace->useGetCMYKLine()); }
1222
- bool useDeviceNLine() const { return (colorSpace2 && colorSpace2->useGetDeviceNLine()) || (!colorSpace2 && colorSpace->useGetDeviceNLine()); }
1223
-
1224
- // Convert an image pixel to a color.
1225
- void getGray(const unsigned char *x, GfxGray *gray);
1226
- void getRGB(const unsigned char *x, GfxRGB *rgb);
1227
- void getRGBLine(unsigned char *in, unsigned int *out, int length);
1228
- void getRGBLine(unsigned char *in, unsigned char *out, int length);
1229
- void getRGBXLine(unsigned char *in, unsigned char *out, int length);
1230
- void getGrayLine(unsigned char *in, unsigned char *out, int length);
1231
- void getCMYKLine(unsigned char *in, unsigned char *out, int length);
1232
- void getDeviceNLine(unsigned char *in, unsigned char *out, int length);
1233
- void getCMYK(const unsigned char *x, GfxCMYK *cmyk);
1234
- void getDeviceN(const unsigned char *x, GfxColor *deviceN);
1235
- void getColor(const unsigned char *x, GfxColor *color);
1236
-
1237
- // Matte color ops
1238
- void setMatteColor(const GfxColor *color)
1239
- {
1240
- useMatte = true;
1241
- matteColor = *color;
1242
- }
1243
- const GfxColor *getMatteColor() const { return (useMatte) ? &matteColor : nullptr; }
1244
-
1245
- private:
1246
- explicit GfxImageColorMap(const GfxImageColorMap *colorMap);
1247
-
1248
- GfxColorSpace *colorSpace; // the image color space
1249
- int bits; // bits per component
1250
- int nComps; // number of components in a pixel
1251
- GfxColorSpace *colorSpace2; // secondary color space
1252
- int nComps2; // number of components in colorSpace2
1253
- GfxColorComp * // lookup table
1254
- lookup[gfxColorMaxComps];
1255
- GfxColorComp * // optimized case lookup table
1256
- lookup2[gfxColorMaxComps];
1257
- unsigned char *byte_lookup;
1258
- double // minimum values for each component
1259
- decodeLow[gfxColorMaxComps];
1260
- double // max - min value for each component
1261
- decodeRange[gfxColorMaxComps];
1262
- bool useMatte;
1263
- GfxColor matteColor;
1264
- bool ok;
1265
- };
1266
-
1267
- //------------------------------------------------------------------------
1268
- // GfxSubpath and GfxPath
1269
- //------------------------------------------------------------------------
1270
-
1271
- class GfxSubpath
1272
- {
1273
- public:
1274
- // Constructor.
1275
- GfxSubpath(double x1, double y1);
1276
-
1277
- // Destructor.
1278
- ~GfxSubpath();
1279
-
1280
- GfxSubpath(const GfxSubpath &) = delete;
1281
- GfxSubpath &operator=(const GfxSubpath &) = delete;
1282
-
1283
- // Copy.
1284
- GfxSubpath *copy() const { return new GfxSubpath(this); }
1285
-
1286
- // Get points.
1287
- int getNumPoints() const { return n; }
1288
- double getX(int i) const { return x[i]; }
1289
- double getY(int i) const { return y[i]; }
1290
- bool getCurve(int i) const { return curve[i]; }
1291
-
1292
- void setX(int i, double a) { x[i] = a; }
1293
- void setY(int i, double a) { y[i] = a; }
1294
-
1295
- // Get last point.
1296
- double getLastX() const { return x[n - 1]; }
1297
- double getLastY() const { return y[n - 1]; }
1298
-
1299
- // Add a line segment.
1300
- void lineTo(double x1, double y1);
1301
-
1302
- // Add a Bezier curve.
1303
- void curveTo(double x1, double y1, double x2, double y2, double x3, double y3);
1304
-
1305
- // Close the subpath.
1306
- void close();
1307
- bool isClosed() const { return closed; }
1308
-
1309
- // Add (<dx>, <dy>) to each point in the subpath.
1310
- void offset(double dx, double dy);
1311
-
1312
- private:
1313
- double *x, *y; // points
1314
- bool *curve; // curve[i] => point i is a control point
1315
- // for a Bezier curve
1316
- int n; // number of points
1317
- int size; // size of x/y arrays
1318
- bool closed; // set if path is closed
1319
-
1320
- explicit GfxSubpath(const GfxSubpath *subpath);
1321
- };
1322
-
1323
- class POPPLER_PRIVATE_EXPORT GfxPath
1324
- {
1325
- public:
1326
- // Constructor.
1327
- GfxPath();
1328
-
1329
- // Destructor.
1330
- ~GfxPath();
1331
-
1332
- GfxPath(const GfxPath &) = delete;
1333
- GfxPath &operator=(const GfxPath &) = delete;
1334
-
1335
- // Copy.
1336
- GfxPath *copy() const { return new GfxPath(justMoved, firstX, firstY, subpaths, n, size); }
1337
-
1338
- // Is there a current point?
1339
- bool isCurPt() const { return n > 0 || justMoved; }
1340
-
1341
- // Is the path non-empty, i.e., is there at least one segment?
1342
- bool isPath() const { return n > 0; }
1343
-
1344
- // Get subpaths.
1345
- int getNumSubpaths() const { return n; }
1346
- GfxSubpath *getSubpath(int i) { return subpaths[i]; }
1347
- const GfxSubpath *getSubpath(int i) const { return subpaths[i]; }
1348
-
1349
- // Get last point on last subpath.
1350
- double getLastX() const { return subpaths[n - 1]->getLastX(); }
1351
- double getLastY() const { return subpaths[n - 1]->getLastY(); }
1352
-
1353
- // Move the current point.
1354
- void moveTo(double x, double y);
1355
-
1356
- // Add a segment to the last subpath.
1357
- void lineTo(double x, double y);
1358
-
1359
- // Add a Bezier curve to the last subpath
1360
- void curveTo(double x1, double y1, double x2, double y2, double x3, double y3);
1361
-
1362
- // Close the last subpath.
1363
- void close();
1364
-
1365
- // Append <path> to <this>.
1366
- void append(GfxPath *path);
1367
-
1368
- // Add (<dx>, <dy>) to each point in the path.
1369
- void offset(double dx, double dy);
1370
-
1371
- private:
1372
- bool justMoved; // set if a new subpath was just started
1373
- double firstX, firstY; // first point in new subpath
1374
- GfxSubpath **subpaths; // subpaths
1375
- int n; // number of subpaths
1376
- int size; // size of subpaths array
1377
-
1378
- GfxPath(bool justMoved1, double firstX1, double firstY1, GfxSubpath **subpaths1, int n1, int size1);
1379
- };
1380
-
1381
- //------------------------------------------------------------------------
1382
- // GfxState
1383
- //------------------------------------------------------------------------
1384
-
1385
- class POPPLER_PRIVATE_EXPORT GfxState
1386
- {
1387
- public:
1388
- /**
1389
- * When GfxState::getReusablePath() is invoked, the currently active
1390
- * path is taken per reference and its coordinates can be re-edited.
1391
- *
1392
- * A ReusablePathIterator is intended to reduce overhead when the same
1393
- * path type is used a lot of times, only with different coordinates. It
1394
- * allows just to update the coordinates (occurring in the same order as
1395
- * in the original path).
1396
- */
1397
- class ReusablePathIterator
1398
- {
1399
- public:
1400
- /**
1401
- * Creates the ReusablePathIterator. This should only be done from
1402
- * GfxState::getReusablePath().
1403
- *
1404
- * @param path the path as it is used so far. Changing this path,
1405
- * deleting it or starting a new path from scratch will most likely
1406
- * invalidate the iterator (and may cause serious problems). Make
1407
- * sure the path's memory structure is not changed during the
1408
- * lifetime of the ReusablePathIterator.
1409
- */
1410
- explicit ReusablePathIterator(GfxPath *path);
1411
-
1412
- /**
1413
- * Returns true if and only if the current iterator position is
1414
- * beyond the last valid point.
1415
- *
1416
- * A call to setCoord() will be undefined.
1417
- */
1418
- bool isEnd() const;
1419
-
1420
- /**
1421
- * Advances the iterator.
1422
- */
1423
- void next();
1424
-
1425
- /**
1426
- * Updates the coordinates associated to the current iterator
1427
- * position.
1428
- */
1429
- void setCoord(double x, double y);
1430
-
1431
- /**
1432
- * Resets the iterator.
1433
- */
1434
- void reset();
1435
-
1436
- private:
1437
- GfxPath *path;
1438
- int subPathOff;
1439
-
1440
- int coordOff;
1441
- int numCoords;
1442
-
1443
- GfxSubpath *curSubPath;
1444
- };
1445
-
1446
- // Construct a default GfxState, for a device with resolution <hDPI>
1447
- // x <vDPI>, page box <pageBox>, page rotation <rotateA>, and
1448
- // coordinate system specified by <upsideDown>.
1449
- GfxState(double hDPIA, double vDPIA, const PDFRectangle *pageBox, int rotateA, bool upsideDown);
1450
-
1451
- // Destructor.
1452
- ~GfxState();
1453
-
1454
- GfxState(const GfxState &) = delete;
1455
- GfxState &operator=(const GfxState &) = delete;
1456
-
1457
- // Copy.
1458
- GfxState *copy(bool copyPath = false) const { return new GfxState(this, copyPath); }
1459
-
1460
- // Accessors.
1461
- double getHDPI() const { return hDPI; }
1462
- double getVDPI() const { return vDPI; }
1463
- const double *getCTM() const { return ctm; }
1464
- void getCTM(Matrix *m) const { memcpy(m->m, ctm, sizeof m->m); }
1465
- double getX1() const { return px1; }
1466
- double getY1() const { return py1; }
1467
- double getX2() const { return px2; }
1468
- double getY2() const { return py2; }
1469
- double getPageWidth() const { return pageWidth; }
1470
- double getPageHeight() const { return pageHeight; }
1471
- int getRotate() const { return rotate; }
1472
- const GfxColor *getFillColor() const { return &fillColor; }
1473
- const GfxColor *getStrokeColor() const { return &strokeColor; }
1474
- void getFillGray(GfxGray *gray) { fillColorSpace->getGray(&fillColor, gray); }
1475
- void getStrokeGray(GfxGray *gray) { strokeColorSpace->getGray(&strokeColor, gray); }
1476
- void getFillRGB(GfxRGB *rgb) const { fillColorSpace->getRGB(&fillColor, rgb); }
1477
- void getStrokeRGB(GfxRGB *rgb) const { strokeColorSpace->getRGB(&strokeColor, rgb); }
1478
- void getFillCMYK(GfxCMYK *cmyk) { fillColorSpace->getCMYK(&fillColor, cmyk); }
1479
- void getFillDeviceN(GfxColor *deviceN) { fillColorSpace->getDeviceN(&fillColor, deviceN); }
1480
- void getStrokeCMYK(GfxCMYK *cmyk) { strokeColorSpace->getCMYK(&strokeColor, cmyk); }
1481
- void getStrokeDeviceN(GfxColor *deviceN) { strokeColorSpace->getDeviceN(&strokeColor, deviceN); }
1482
- GfxColorSpace *getFillColorSpace() { return fillColorSpace; }
1483
- GfxColorSpace *getStrokeColorSpace() { return strokeColorSpace; }
1484
- GfxPattern *getFillPattern() { return fillPattern; }
1485
- GfxPattern *getStrokePattern() { return strokePattern; }
1486
- GfxBlendMode getBlendMode() const { return blendMode; }
1487
- double getFillOpacity() const { return fillOpacity; }
1488
- double getStrokeOpacity() const { return strokeOpacity; }
1489
- bool getFillOverprint() const { return fillOverprint; }
1490
- bool getStrokeOverprint() const { return strokeOverprint; }
1491
- int getOverprintMode() const { return overprintMode; }
1492
- Function **getTransfer() { return transfer; }
1493
- double getLineWidth() const { return lineWidth; }
1494
- void getLineDash(double **dash, int *length, double *start)
1495
- {
1496
- *dash = lineDash;
1497
- *length = lineDashLength;
1498
- *start = lineDashStart;
1499
- }
1500
- int getFlatness() const { return flatness; }
1501
- int getLineJoin() const { return lineJoin; }
1502
- int getLineCap() const { return lineCap; }
1503
- double getMiterLimit() const { return miterLimit; }
1504
- bool getStrokeAdjust() const { return strokeAdjust; }
1505
- bool getAlphaIsShape() const { return alphaIsShape; }
1506
- bool getTextKnockout() const { return textKnockout; }
1507
- const std::shared_ptr<GfxFont> &getFont() const { return font; }
1508
- double getFontSize() const { return fontSize; }
1509
- const double *getTextMat() const { return textMat; }
1510
- double getCharSpace() const { return charSpace; }
1511
- double getWordSpace() const { return wordSpace; }
1512
- double getHorizScaling() const { return horizScaling; }
1513
- double getLeading() const { return leading; }
1514
- double getRise() const { return rise; }
1515
- int getRender() const { return render; }
1516
- const char *getRenderingIntent() const { return renderingIntent; }
1517
- const GfxPath *getPath() const { return path; }
1518
- void setPath(GfxPath *pathA);
1519
- double getCurX() const { return curX; }
1520
- double getCurY() const { return curY; }
1521
- void getClipBBox(double *xMin, double *yMin, double *xMax, double *yMax) const
1522
- {
1523
- *xMin = clipXMin;
1524
- *yMin = clipYMin;
1525
- *xMax = clipXMax;
1526
- *yMax = clipYMax;
1527
- }
1528
- void getUserClipBBox(double *xMin, double *yMin, double *xMax, double *yMax) const;
1529
- double getLineX() const { return lineX; }
1530
- double getLineY() const { return lineY; }
1531
-
1532
- // Is there a current point/path?
1533
- bool isCurPt() const { return path->isCurPt(); }
1534
- bool isPath() const { return path->isPath(); }
1535
-
1536
- // Transforms.
1537
- void transform(double x1, double y1, double *x2, double *y2) const
1538
- {
1539
- *x2 = ctm[0] * x1 + ctm[2] * y1 + ctm[4];
1540
- *y2 = ctm[1] * x1 + ctm[3] * y1 + ctm[5];
1541
- }
1542
- void transformDelta(double x1, double y1, double *x2, double *y2) const
1543
- {
1544
- *x2 = ctm[0] * x1 + ctm[2] * y1;
1545
- *y2 = ctm[1] * x1 + ctm[3] * y1;
1546
- }
1547
- void textTransform(double x1, double y1, double *x2, double *y2) const
1548
- {
1549
- *x2 = textMat[0] * x1 + textMat[2] * y1 + textMat[4];
1550
- *y2 = textMat[1] * x1 + textMat[3] * y1 + textMat[5];
1551
- }
1552
- void textTransformDelta(double x1, double y1, double *x2, double *y2) const
1553
- {
1554
- *x2 = textMat[0] * x1 + textMat[2] * y1;
1555
- *y2 = textMat[1] * x1 + textMat[3] * y1;
1556
- }
1557
- double transformWidth(double w) const;
1558
- double getTransformedLineWidth() const { return transformWidth(lineWidth); }
1559
- double getTransformedFontSize() const;
1560
- void getFontTransMat(double *m11, double *m12, double *m21, double *m22) const;
1561
-
1562
- // Change state parameters.
1563
- void setCTM(double a, double b, double c, double d, double e, double f);
1564
- void concatCTM(double a, double b, double c, double d, double e, double f);
1565
- void shiftCTMAndClip(double tx, double ty);
1566
- void setFillColorSpace(GfxColorSpace *colorSpace);
1567
- void setStrokeColorSpace(GfxColorSpace *colorSpace);
1568
- void setFillColor(const GfxColor *color) { fillColor = *color; }
1569
- void setStrokeColor(const GfxColor *color) { strokeColor = *color; }
1570
- void setFillPattern(GfxPattern *pattern);
1571
- void setStrokePattern(GfxPattern *pattern);
1572
- void setBlendMode(GfxBlendMode mode) { blendMode = mode; }
1573
- void setFillOpacity(double opac) { fillOpacity = opac; }
1574
- void setStrokeOpacity(double opac) { strokeOpacity = opac; }
1575
- void setFillOverprint(bool op) { fillOverprint = op; }
1576
- void setStrokeOverprint(bool op) { strokeOverprint = op; }
1577
- void setOverprintMode(int op) { overprintMode = op; }
1578
- void setTransfer(Function **funcs);
1579
- void setLineWidth(double width) { lineWidth = width; }
1580
- void setLineDash(double *dash, int length, double start);
1581
- void setFlatness(int flatness1) { flatness = flatness1; }
1582
- void setLineJoin(int lineJoin1) { lineJoin = lineJoin1; }
1583
- void setLineCap(int lineCap1) { lineCap = lineCap1; }
1584
- void setMiterLimit(double limit) { miterLimit = limit; }
1585
- void setStrokeAdjust(bool sa) { strokeAdjust = sa; }
1586
- void setAlphaIsShape(bool ais) { alphaIsShape = ais; }
1587
- void setTextKnockout(bool tk) { textKnockout = tk; }
1588
- void setFont(std::shared_ptr<GfxFont> fontA, double fontSizeA);
1589
- void setTextMat(double a, double b, double c, double d, double e, double f)
1590
- {
1591
- textMat[0] = a;
1592
- textMat[1] = b;
1593
- textMat[2] = c;
1594
- textMat[3] = d;
1595
- textMat[4] = e;
1596
- textMat[5] = f;
1597
- }
1598
- void setCharSpace(double space) { charSpace = space; }
1599
- void setWordSpace(double space) { wordSpace = space; }
1600
- void setHorizScaling(double scale) { horizScaling = 0.01 * scale; }
1601
- void setLeading(double leadingA) { leading = leadingA; }
1602
- void setRise(double riseA) { rise = riseA; }
1603
- void setRender(int renderA) { render = renderA; }
1604
- void setRenderingIntent(const char *intent) { strncpy(renderingIntent, intent, 31); }
1605
-
1606
- #ifdef USE_CMS
1607
- void setDisplayProfile(const GfxLCMSProfilePtr &localDisplayProfileA);
1608
- GfxLCMSProfilePtr getDisplayProfile() { return localDisplayProfile; }
1609
- std::shared_ptr<GfxColorTransform> getXYZ2DisplayTransform();
1610
- int getCmsRenderingIntent();
1611
- static GfxLCMSProfilePtr sRGBProfile;
1612
- #endif
1613
-
1614
- void setDefaultGrayColorSpace(GfxColorSpace *cs) { defaultGrayColorSpace = cs; }
1615
-
1616
- void setDefaultRGBColorSpace(GfxColorSpace *cs) { defaultRGBColorSpace = cs; }
1617
-
1618
- void setDefaultCMYKColorSpace(GfxColorSpace *cs) { defaultCMYKColorSpace = cs; }
1619
-
1620
- GfxColorSpace *copyDefaultGrayColorSpace()
1621
- {
1622
- if (defaultGrayColorSpace) {
1623
- return defaultGrayColorSpace->copy();
1624
- }
1625
- return new GfxDeviceGrayColorSpace();
1626
- }
1627
-
1628
- GfxColorSpace *copyDefaultRGBColorSpace()
1629
- {
1630
- if (defaultRGBColorSpace) {
1631
- return defaultRGBColorSpace->copy();
1632
- }
1633
- return new GfxDeviceRGBColorSpace();
1634
- }
1635
-
1636
- GfxColorSpace *copyDefaultCMYKColorSpace()
1637
- {
1638
- if (defaultCMYKColorSpace) {
1639
- return defaultCMYKColorSpace->copy();
1640
- }
1641
- return new GfxDeviceCMYKColorSpace();
1642
- }
1643
-
1644
- // Add to path.
1645
- void moveTo(double x, double y) { path->moveTo(curX = x, curY = y); }
1646
- void lineTo(double x, double y) { path->lineTo(curX = x, curY = y); }
1647
- void curveTo(double x1, double y1, double x2, double y2, double x3, double y3) { path->curveTo(x1, y1, x2, y2, curX = x3, curY = y3); }
1648
- void closePath()
1649
- {
1650
- path->close();
1651
- curX = path->getLastX();
1652
- curY = path->getLastY();
1653
- }
1654
- void clearPath();
1655
-
1656
- // Update clip region.
1657
- void clip();
1658
- void clipToStrokePath();
1659
- void clipToRect(double xMin, double yMin, double xMax, double yMax);
1660
-
1661
- // Text position.
1662
- void textSetPos(double tx, double ty)
1663
- {
1664
- lineX = tx;
1665
- lineY = ty;
1666
- }
1667
- void textMoveTo(double tx, double ty)
1668
- {
1669
- lineX = tx;
1670
- lineY = ty;
1671
- textTransform(tx, ty, &curX, &curY);
1672
- }
1673
- void textShift(double tx, double ty);
1674
- void shift(double dx, double dy);
1675
-
1676
- // Push/pop GfxState on/off stack.
1677
- GfxState *save();
1678
- GfxState *restore();
1679
- bool hasSaves() const { return saved != nullptr; }
1680
- bool isParentState(GfxState *state) { return saved == state || (saved && saved->isParentState(state)); }
1681
-
1682
- // Misc
1683
- bool parseBlendMode(Object *obj, GfxBlendMode *mode);
1684
-
1685
- ReusablePathIterator *getReusablePath() { return new ReusablePathIterator(path); }
1686
-
1687
- private:
1688
- double hDPI, vDPI; // resolution
1689
- double ctm[6]; // coord transform matrix
1690
- double px1, py1, px2, py2; // page corners (user coords)
1691
- double pageWidth, pageHeight; // page size (pixels)
1692
- int rotate; // page rotation angle
1693
-
1694
- GfxColorSpace *fillColorSpace; // fill color space
1695
- GfxColorSpace *strokeColorSpace; // stroke color space
1696
- GfxColor fillColor; // fill color
1697
- GfxColor strokeColor; // stroke color
1698
- GfxPattern *fillPattern; // fill pattern
1699
- GfxPattern *strokePattern; // stroke pattern
1700
- GfxBlendMode blendMode; // transparency blend mode
1701
- double fillOpacity; // fill opacity
1702
- double strokeOpacity; // stroke opacity
1703
- bool fillOverprint; // fill overprint
1704
- bool strokeOverprint; // stroke overprint
1705
- int overprintMode; // overprint mode
1706
- Function *transfer[4]; // transfer function (entries may be: all
1707
- // nullptr = identity; last three nullptr =
1708
- // single function; all four non-nullptr =
1709
- // R,G,B,gray functions)
1710
-
1711
- double lineWidth; // line width
1712
- double *lineDash; // line dash
1713
- int lineDashLength;
1714
- double lineDashStart;
1715
- int flatness; // curve flatness
1716
- int lineJoin; // line join style
1717
- int lineCap; // line cap style
1718
- double miterLimit; // line miter limit
1719
- bool strokeAdjust; // stroke adjustment
1720
- bool alphaIsShape; // alpha is shape
1721
- bool textKnockout; // text knockout
1722
-
1723
- std::shared_ptr<GfxFont> font; // font
1724
- double fontSize; // font size
1725
- double textMat[6]; // text matrix
1726
- double charSpace; // character spacing
1727
- double wordSpace; // word spacing
1728
- double horizScaling; // horizontal scaling
1729
- double leading; // text leading
1730
- double rise; // text rise
1731
- int render; // text rendering mode
1732
-
1733
- GfxPath *path; // array of path elements
1734
- double curX, curY; // current point (user coords)
1735
- double lineX, lineY; // start of current text line (text coords)
1736
-
1737
- double clipXMin, clipYMin, // bounding box for clip region
1738
- clipXMax, clipYMax;
1739
- char renderingIntent[32];
1740
-
1741
- GfxState *saved; // next GfxState on stack
1742
-
1743
- GfxState(const GfxState *state, bool copyPath);
1744
-
1745
- #ifdef USE_CMS
1746
- GfxLCMSProfilePtr localDisplayProfile;
1747
- std::shared_ptr<GfxColorTransform> XYZ2DisplayTransformRelCol;
1748
- std::shared_ptr<GfxColorTransform> XYZ2DisplayTransformAbsCol;
1749
- std::shared_ptr<GfxColorTransform> XYZ2DisplayTransformSat;
1750
- std::shared_ptr<GfxColorTransform> XYZ2DisplayTransformPerc;
1751
- static GfxLCMSProfilePtr XYZProfile;
1752
- #endif
1753
-
1754
- GfxColorSpace *defaultGrayColorSpace;
1755
- GfxColorSpace *defaultRGBColorSpace;
1756
- GfxColorSpace *defaultCMYKColorSpace;
1757
- };
1758
-
1759
- #endif