1 //======================================================================== 2 // 3 // SplashBitmap.h 4 // 5 //======================================================================== 6 7 //======================================================================== 8 // 9 // Modified under the Poppler project - http://poppler.freedesktop.org 10 // 11 // All changes made under the Poppler project to this file are licensed 12 // under GPL version 2 or later 13 // 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 // 24 // To see a description of the changes please see the Changelog file that 25 // came with your tarball or type make ChangeLog if you are building from git 26 // 27 //======================================================================== 28 29 #ifndef SPLASHBITMAP_H 30 #define SPLASHBITMAP_H 31 32 #ifdef USE_GCC_PRAGMAS 33 #pragma interface 34 #endif 35 36 #include "SplashTypes.h" 37 #include "poppler/GfxState.h" 38 #include <stdio.h> 39 40 class ImgWriter; 41 42 //------------------------------------------------------------------------ 43 // SplashBitmap 44 //------------------------------------------------------------------------ 45 46 class SplashBitmap { 47 public: 48 49 // Create a new bitmap. It will have <widthA> x <heightA> pixels in 50 // color mode <modeA>. Rows will be padded out to a multiple of 51 // <rowPad> bytes. If <topDown> is false, the bitmap will be stored 52 // upside-down, i.e., with the last row first in memory. 53 SplashBitmap(int widthA, int heightA, int rowPad, 54 SplashColorMode modeA, GBool alphaA, 55 GBool topDown = gTrue, GooList *separationList = NULL); 56 static SplashBitmap *copy(SplashBitmap *src); 57 58 ~SplashBitmap(); 59 getWidth()60 int getWidth() { return width; } getHeight()61 int getHeight() { return height; } getRowSize()62 int getRowSize() { return rowSize; } getAlphaRowSize()63 int getAlphaRowSize() { return width; } getRowPad()64 int getRowPad() { return rowPad; } getMode()65 SplashColorMode getMode() { return mode; } getDataPtr()66 SplashColorPtr getDataPtr() { return data; } getAlphaPtr()67 Guchar *getAlphaPtr() { return alpha; } getSeparationList()68 GooList *getSeparationList() { return separationList; } 69 70 SplashError writePNMFile(char *fileName); 71 SplashError writePNMFile(FILE *f); 72 SplashError writeAlphaPGMFile(char *fileName); 73 74 SplashError writeImgFile(SplashImageFileFormat format, char *fileName, int hDPI, int vDPI, const char *compressionString = ""); 75 SplashError writeImgFile(SplashImageFileFormat format, FILE *f, int hDPI, int vDPI, const char *compressionString = ""); 76 SplashError writeImgFile(ImgWriter *writer, FILE *f, int hDPI, int vDPI); 77 78 GBool convertToXBGR(); 79 80 void getPixel(int x, int y, SplashColorPtr pixel); 81 void getRGBLine(int y, SplashColorPtr line); 82 void getXBGRLine(int y, SplashColorPtr line); 83 #if SPLASH_CMYK 84 void getCMYKLine(int y, SplashColorPtr line); 85 #endif 86 Guchar getAlpha(int x, int y); 87 88 // Caller takes ownership of the bitmap data. The SplashBitmap 89 // object is no longer valid -- the next call should be to the 90 // destructor. 91 SplashColorPtr takeData(); 92 93 private: 94 95 int width, height; // size of bitmap 96 int rowPad; 97 int rowSize; // size of one row of data, in bytes 98 // - negative for bottom-up bitmaps 99 SplashColorMode mode; // color mode 100 SplashColorPtr data; // pointer to row zero of the color data 101 Guchar *alpha; // pointer to row zero of the alpha data 102 // (always top-down) 103 GooList *separationList; // list of spot colorants and their mapping functions 104 105 friend class Splash; 106 }; 107 108 #endif 109