/src/xpdf-4.04/splash/SplashBitmap.h
Line | Count | Source (jump to first uncovered line) |
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 <limits.h> |
20 | | // older compilers won't define SIZE_MAX in stdint.h without this |
21 | | #ifndef __STDC_LIMIT_MACROS |
22 | | # define __STDC_LIMIT_MACROS 1 |
23 | | #endif |
24 | | #include <stdint.h> |
25 | | #include "SplashTypes.h" |
26 | | |
27 | | //------------------------------------------------------------------------ |
28 | | |
29 | | // ssize_t isn't well-defined, so define our own |
30 | | #if SIZE_MAX == UINT_MAX |
31 | | typedef int SplashBitmapRowSize; |
32 | | # define SplashBitmapRowSizeMax INT_MAX |
33 | | #else |
34 | | typedef long long SplashBitmapRowSize; |
35 | | # define SplashBitmapRowSizeMax LLONG_MAX |
36 | | #endif |
37 | | |
38 | | //------------------------------------------------------------------------ |
39 | | // SplashBitmap |
40 | | //------------------------------------------------------------------------ |
41 | | |
42 | | class SplashBitmap { |
43 | | public: |
44 | | |
45 | | // Create a new bitmap. It will have <widthA> x <heightA> pixels in |
46 | | // color mode <modeA>. Rows will be padded out to a multiple of |
47 | | // <rowPad> bytes. If <topDown> is false, the bitmap will be stored |
48 | | // upside-down, i.e., with the last row first in memory. |
49 | | SplashBitmap(int widthA, int heightA, int rowPad, |
50 | | SplashColorMode modeA, GBool alphaA, |
51 | | GBool topDown, SplashBitmap *parentA); |
52 | | |
53 | | ~SplashBitmap(); |
54 | | |
55 | 0 | int getWidth() { return width; } |
56 | 0 | int getHeight() { return height; } |
57 | 0 | SplashBitmapRowSize getRowSize() { return rowSize; } |
58 | 0 | size_t getAlphaRowSize() { return alphaRowSize; } |
59 | 0 | SplashColorMode getMode() { return mode; } |
60 | 0 | SplashColorPtr getDataPtr() { return data; } |
61 | 0 | Guchar *getAlphaPtr() { return alpha; } |
62 | | |
63 | | SplashError writePNMFile(char *fileName); |
64 | | SplashError writePNMFile(FILE *f); |
65 | | SplashError writeAlphaPGMFile(char *fileName); |
66 | | |
67 | | void getPixel(int x, int y, SplashColorPtr pixel); |
68 | | Guchar getAlpha(int x, int y); |
69 | | |
70 | | // Caller takes ownership of the bitmap data. The SplashBitmap |
71 | | // object is no longer valid -- the next call should be to the |
72 | | // destructor. |
73 | | SplashColorPtr takeData(); |
74 | | |
75 | | private: |
76 | | |
77 | | int width, height; // size of bitmap |
78 | | SplashBitmapRowSize rowSize; // size of one row of data, in bytes |
79 | | // - negative for bottom-up bitmaps |
80 | | size_t alphaRowSize; // size of one row of alpha, in bytes |
81 | | SplashColorMode mode; // color mode |
82 | | SplashColorPtr data; // pointer to row zero of the color data |
83 | | Guchar *alpha; // pointer to row zero of the alpha data |
84 | | // (always top-down) |
85 | | |
86 | | // save the last-allocated (large) bitmap data and reuse if possible |
87 | | SplashBitmap *parent; |
88 | | SplashColorPtr oldData; |
89 | | Guchar *oldAlpha; |
90 | | SplashBitmapRowSize oldRowSize; |
91 | | size_t oldAlphaRowSize; |
92 | | int oldHeight; |
93 | | |
94 | | friend class Splash; |
95 | | }; |
96 | | |
97 | | |
98 | | #endif |