1 //========================================================================
2 //
3 // SplashBitmap.h
4 //
5 // Copyright 2003-2013 Glyph & Cog, LLC
6 //
7 //========================================================================
8 
9 #ifndef SPLASHBITMAP_H
10 #define SPLASHBITMAP_H
11 
12 #include <aconf.h>
13 
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
17 
18 #include <stdio.h>
19 #include "SplashTypes.h"
20 
21 //------------------------------------------------------------------------
22 // SplashBitmap
23 //------------------------------------------------------------------------
24 
25 class SplashBitmap {
26 public:
27 
28   // Create a new bitmap.  It will have <widthA> x <heightA> pixels in
29   // color mode <modeA>.  Rows will be padded out to a multiple of
30   // <rowPad> bytes.  If <topDown> is false, the bitmap will be stored
31   // upside-down, i.e., with the last row first in memory.
32   SplashBitmap(int widthA, int heightA, int rowPad,
33 	       SplashColorMode modeA, GBool alphaA,
34 	       GBool topDown = gTrue);
35 
36   ~SplashBitmap();
37 
getWidth()38   int getWidth() { return width; }
getHeight()39   int getHeight() { return height; }
getRowSize()40   int getRowSize() { return rowSize; }
getAlphaRowSize()41   int getAlphaRowSize() { return width; }
getMode()42   SplashColorMode getMode() { return mode; }
getDataPtr()43   SplashColorPtr getDataPtr() { return data; }
getAlphaPtr()44   Guchar *getAlphaPtr() { return alpha; }
45 
46   SplashError writePNMFile(char *fileName);
47   SplashError writePNMFile(FILE *f);
48   SplashError writeAlphaPGMFile(char *fileName);
49 
50   void getPixel(int x, int y, SplashColorPtr pixel);
51   Guchar getAlpha(int x, int y);
52 
53   // Caller takes ownership of the bitmap data.  The SplashBitmap
54   // object is no longer valid -- the next call should be to the
55   // destructor.
56   SplashColorPtr takeData();
57 
58 private:
59 
60   int width, height;		// size of bitmap
61   int rowSize;			// size of one row of data, in bytes
62 				//   - negative for bottom-up bitmaps
63   SplashColorMode mode;		// color mode
64   SplashColorPtr data;		// pointer to row zero of the color data
65   Guchar *alpha;		// pointer to row zero of the alpha data
66 				//   (always top-down)
67 
68   friend class Splash;
69 };
70 
71 #endif
72