1
///////////////////////////////////////////////////////////////////////////////
4
// Author: Ulrich Telle
7
// Copyright: (c) Ulrich Telle
8
// Licence: wxWindows licence
9
///////////////////////////////////////////////////////////////////////////////
11
/// \file pdfimage.h Interface of the wxPdfImage class
16
#include <wx/filesys.h>
19
#include "wx/pdfdocdef.h"
21
// Forward declarations
23
class WXDLLIMPEXP_PDFDOC wxPdfDocument;
25
/// Class representing image objects. (For internal use only)
26
class WXDLLIMPEXP_PDFDOC wxPdfImage
30
wxPdfImage(wxPdfDocument* document, int index, const wxString& name, const wxString& type);
33
wxPdfImage(wxPdfDocument* document, int index, const wxString& name, const wxImage& image);
36
wxPdfImage(wxPdfDocument* document, int index, const wxString& name, wxInputStream& stream, const wxString& mimeType);
39
virtual ~wxPdfImage();
42
void SetIndex(int index) { m_index = index; }
45
int GetIndex() { return m_index; }
48
void SetObjIndex(int n) { m_n = n; }
51
int GetObjIndex() { return m_n; }
54
void SetMaskImage(int maskImage) { m_maskImage = maskImage; }
57
int GetMaskImage() { return m_maskImage; }
60
void SetType(const wxString& type) { m_type = type; }
63
wxString GetType() { return m_type; }
65
/// Check whether image has to be handled as a form object
66
bool IsFormObject() { return m_isFormObj; }
68
/// Set image file name
69
void SetName(const wxString& name) { m_name = name; }
71
/// Get image file name
72
wxString GetName() { return m_name; }
74
/// Get image width in pixels
75
int GetWidth() { return m_width; }
77
/// Get image height in pixels
78
int GetHeight() { return m_height; }
80
/// Get image offset in X direction
81
int GetX() { return m_x; }
83
/// Get image offset in Y direction
84
int GetY() { return m_y; }
87
wxString GetColorSpace() { return m_cs; }
89
/// Get bits per component
90
int GetBitsPerComponent() { return m_bpc; }
92
/// Get compression filter specification
93
wxString GetF() { return m_f; }
95
/// Get additional PDF parameter
96
wxString GetParms() { return m_parms; }
99
int GetPaletteSize() { return m_palSize; }
102
char* GetPalette() { return m_pal; }
104
/// Get transparency size
105
int GetTransparencySize() { return m_trnsSize; }
107
/// Get transparency data
108
char* GetTransparency() { return m_trns; }
110
/// Get image data size
111
int GetDataSize() { return m_dataSize; }
114
char* GetData() { return m_data; }
120
/// Extract info from a wxImage
121
bool ConvertWxImage(const wxImage& image);
123
/// Extract info from a JPEG file
124
bool ParseJPG(wxInputStream* imageStream);
126
/// Extract info from a PNG file
127
bool ParsePNG(wxInputStream* imageStream);
129
/// Extract info from a GIF file
130
bool ParseGIF(wxInputStream* imageStream);
132
/// Extract info from a WMF file
133
bool ParseWMF(wxInputStream* imageStream);
135
/// Read a 4-byte integer from file (big endian)
136
int ReadIntBE(wxInputStream* imageStream);
138
/// Read a 4-byte integer from file (little endian)
139
int ReadIntLE(wxInputStream* imageStream);
141
/// Read a 4-byte unsigned integer from file (big endian)
142
unsigned int ReadUIntBE(wxInputStream* imageStream);
144
/// Read a 4-byte unsigned integer from file (little endian)
145
unsigned int ReadUIntLE(wxInputStream* imageStream);
147
/// Read a 2-byte integer from file (big endian)
148
short ReadShortBE(wxInputStream* imageStream);
150
/// Read a 2-byte integer from file (little endian)
151
short ReadShortLE(wxInputStream* imageStream);
153
/// Read a unsigned 2-byte integer from file (big endian)
154
unsigned short ReadUShortBE(wxInputStream* imageStream);
156
/// Read a unsigned 2-byte integer from file (little endian)
157
unsigned short ReadUShortLE(wxInputStream* imageStream);
159
/// Get the file system for accessing image files
160
static wxFileSystem* GetFileSystem();
163
wxPdfDocument* m_document; ///< Document this image belongs to
164
int m_index; ///< Index number of this image
165
int m_n; ///< Image object index
166
wxString m_type; ///< Image type
167
wxString m_name; ///< Image name
168
int m_maskImage; ///< Id of associated image mask
170
int m_width; ///< Image width in pixels
171
int m_height; ///< Image height in pixels
172
wxString m_cs; ///< Colorspace
173
char m_bpc; ///< Bits per color
174
wxString m_f; ///< Compression method
175
wxString m_parms; ///< Additional PDF parameters
176
int m_palSize; ///< Size of palette
177
char* m_pal; ///< Palette data
178
int m_trnsSize; ///< Transparency color size
179
char* m_trns; ///< Transparency color data
180
int m_dataSize; ///< Image data size
181
char* m_data; ///< Image data
183
bool m_isFormObj; ///< Flag whether image must be treated as form object
184
int m_x; ///< Offset in X direction
185
int m_y; ///< Offset in Y direction
187
bool m_fromWxImage; ///< Flag whether image originated from wxImage
188
bool m_validWxImage; ///< Flag whether wxImage conversion went ok
190
wxFSFile* m_imageFile; ///< File system file of image
191
wxInputStream* m_imageStream; ///< Stream containing the image data
193
static wxFileSystem* ms_fileSystem; ///< File system for accessing image files