beta-0.89.2
[luatex.git] / source / libs / poppler / poppler-src / splash / SplashBitmap.h
blob4417af73375eb8069f05c21ba863c9d0097b27d3
1 //========================================================================
2 //
3 // SplashBitmap.h
4 //
5 //========================================================================
7 //========================================================================
8 //
9 // Modified under the Poppler project - http://poppler.freedesktop.org
11 // All changes made under the Poppler project to this file are licensed
12 // under GPL version 2 or later
14 // Copyright (C) 2007 Ilmari Heikkinen <ilmari.heikkinen@gmail.com>
15 // Copyright (C) 2009 Shen Liang <shenzhuxi@gmail.com>
16 // Copyright (C) 2009, 2012 Albert Astals Cid <aacid@kde.org>
17 // Copyright (C) 2009 Stefan Thomas <thomas@eload24.com>
18 // Copyright (C) 2010 Adrian Johnson <ajohnson@redneon.com>
19 // Copyright (C) 2010 Harry Roberts <harry.roberts@midnight-labs.org>
20 // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com>
21 // Copyright (C) 2010 William Bader <williambader@hotmail.com>
22 // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de>
23 // Copyright (C) 2015 Adam Reichold <adamreichold@myopera.com>
25 // To see a description of the changes please see the Changelog file that
26 // came with your tarball or type make ChangeLog if you are building from git
28 //========================================================================
30 #ifndef SPLASHBITMAP_H
31 #define SPLASHBITMAP_H
33 #ifdef USE_GCC_PRAGMAS
34 #pragma interface
35 #endif
37 #include "SplashTypes.h"
38 #include "poppler/GfxState.h"
39 #include <stdio.h>
41 class ImgWriter;
43 //------------------------------------------------------------------------
44 // SplashBitmap
45 //------------------------------------------------------------------------
47 class SplashBitmap {
48 public:
50 // Create a new bitmap. It will have <widthA> x <heightA> pixels in
51 // color mode <modeA>. Rows will be padded out to a multiple of
52 // <rowPad> bytes. If <topDown> is false, the bitmap will be stored
53 // upside-down, i.e., with the last row first in memory.
54 SplashBitmap(int widthA, int heightA, int rowPad,
55 SplashColorMode modeA, GBool alphaA,
56 GBool topDown = gTrue, GooList *separationList = NULL);
57 static SplashBitmap *copy(SplashBitmap *src);
59 ~SplashBitmap();
61 int getWidth() { return width; }
62 int getHeight() { return height; }
63 int getRowSize() { return rowSize; }
64 int getAlphaRowSize() { return width; }
65 int getRowPad() { return rowPad; }
66 SplashColorMode getMode() { return mode; }
67 SplashColorPtr getDataPtr() { return data; }
68 Guchar *getAlphaPtr() { return alpha; }
69 GooList *getSeparationList() { return separationList; }
71 SplashError writePNMFile(char *fileName);
72 SplashError writePNMFile(FILE *f);
73 SplashError writeAlphaPGMFile(char *fileName);
75 SplashError writeImgFile(SplashImageFileFormat format, char *fileName, int hDPI, int vDPI, const char *compressionString = "");
76 SplashError writeImgFile(SplashImageFileFormat format, FILE *f, int hDPI, int vDPI, const char *compressionString = "");
77 SplashError writeImgFile(ImgWriter *writer, FILE *f, int hDPI, int vDPI);
79 enum ConversionMode
81 conversionOpaque,
82 conversionAlpha,
83 conversionAlphaPremultiplied
86 GBool convertToXBGR(ConversionMode conversionMode = conversionOpaque);
88 void getPixel(int x, int y, SplashColorPtr pixel);
89 void getRGBLine(int y, SplashColorPtr line);
90 void getXBGRLine(int y, SplashColorPtr line, ConversionMode conversionMode = conversionOpaque);
91 #if SPLASH_CMYK
92 void getCMYKLine(int y, SplashColorPtr line);
93 #endif
94 Guchar getAlpha(int x, int y);
96 // Caller takes ownership of the bitmap data. The SplashBitmap
97 // object is no longer valid -- the next call should be to the
98 // destructor.
99 SplashColorPtr takeData();
101 private:
103 int width, height; // size of bitmap
104 int rowPad;
105 int rowSize; // size of one row of data, in bytes
106 // - negative for bottom-up bitmaps
107 SplashColorMode mode; // color mode
108 SplashColorPtr data; // pointer to row zero of the color data
109 Guchar *alpha; // pointer to row zero of the alpha data
110 // (always top-down)
111 GooList *separationList; // list of spot colorants and their mapping functions
113 friend class Splash;
116 #endif