00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef _WX_IMAGEBLOCK_H_
00013 #define _WX_IMAGEBLOCK_H_
00014
00015 #include "wx/defs.h"
00016 #include "wx/variant.h"
00017 #include "wx/image.h"
00018
00023 class WXDLLIMPEXP_BASE wxDataInputStream;
00024 class WXDLLIMPEXP_BASE wxDataOutputStream;
00025
00026 class wxImageBlock: public wxObject
00027 {
00028 public:
00029 wxImageBlock();
00030 wxImageBlock(const wxImageBlock& block);
00031 ~wxImageBlock();
00032
00033 void Init();
00034 void Clear();
00035
00036
00037
00038
00039
00040
00041 virtual bool MakeImageBlock(const wxString& filename, int imageType, wxImage& image, bool convertToJPEG = true);
00042
00043
00044
00045 virtual bool MakeImageBlock(const wxString& filename, wxImage& image, int imageType = wxBITMAP_TYPE_PNG, int quality = 80);
00046 virtual bool MakeImageBlock(wxImage& image, int imageType = wxBITMAP_TYPE_PNG, int quality = 80);
00047 virtual bool MakeImageBlock(const wxImage& image, int imageType = wxBITMAP_TYPE_PNG, int quality = 80);
00048
00049
00050 bool Write(const wxString& filename);
00051
00052
00053 bool Write(wxOutputStream& stream);
00054 bool Write(wxOutputStream& stream, wxDataOutputStream& dataStream);
00055
00056
00057 bool WriteHex(wxOutputStream& stream);
00058
00059
00060 bool ReadHex(wxInputStream& stream, int length, int imageType);
00061
00062
00063 bool Read(wxInputStream& stream);
00064 bool Read(wxInputStream& stream, wxDataInputStream& dataStream);
00065
00066
00067 void Copy(const wxImageBlock& block);
00068
00069
00070 bool Load(wxImage& image);
00071
00073 void operator=(const wxImageBlock& block);
00074
00076
00077 unsigned char* GetData() const { return m_data; }
00078 size_t GetDataSize() const { return m_dataSize; }
00079 int GetImageType() const { return m_imageType; }
00080
00081 void SetData(unsigned char* image) { m_data = image; }
00082 void SetDataSize(size_t size) { m_dataSize = size; }
00083 void SetImageType(int imageType) { m_imageType = imageType; }
00084
00085 bool Ok() const { return GetData() != NULL; }
00086
00088
00090 static unsigned char* ReadBlock(wxInputStream& stream, size_t size);
00091 static unsigned char* ReadBlock(const wxString& filename, size_t size);
00092
00093
00094 static bool WriteBlock(wxOutputStream& stream, unsigned char* block, size_t size);
00095
00096
00097 static bool WriteBlock(const wxString& filename, unsigned char* block, size_t size);
00098
00099
00100 static int DetermineImageType(const wxString& filename);
00101
00102
00103 static wxString DetermineExtension(int imageType = -1);
00104
00105 protected:
00106
00107
00108 unsigned char* m_data;
00109 size_t m_dataSize;
00110 int m_imageType;
00111 };
00112
00113 #endif
00114