1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #ifndef __GTKBITMAPH__
12 #define __GTKBITMAPH__
15 #include "wx/object.h"
16 #include "wx/string.h"
17 #include "wx/palette.h"
18 #include "wx/gdiobj.h"
21 typedef struct _GdkPixbuf GdkPixbuf
;
24 class WXDLLEXPORT wxPixelDataBase
;
26 //-----------------------------------------------------------------------------
28 //-----------------------------------------------------------------------------
30 class WXDLLIMPEXP_CORE wxMask
;
31 class WXDLLIMPEXP_CORE wxBitmap
;
32 class WXDLLIMPEXP_CORE wxImage
;
34 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
38 class WXDLLIMPEXP_CORE wxMask
: public wxObject
42 wxMask( const wxBitmap
& bitmap
, const wxColour
& colour
);
43 wxMask( const wxBitmap
& bitmap
, int paletteIndex
);
44 wxMask( const wxBitmap
& bitmap
);
47 bool Create( const wxBitmap
& bitmap
, const wxColour
& colour
);
48 bool Create( const wxBitmap
& bitmap
, int paletteIndex
);
49 bool Create( const wxBitmap
& bitmap
);
54 GdkBitmap
*GetBitmap() const;
57 DECLARE_DYNAMIC_CLASS(wxMask
)
60 //-----------------------------------------------------------------------------
62 //-----------------------------------------------------------------------------
64 class WXDLLIMPEXP_CORE wxBitmap
: public wxBitmapBase
68 wxBitmap( int width
, int height
, int depth
= -1 );
69 wxBitmap( const char bits
[], int width
, int height
, int depth
= 1 );
70 wxBitmap( const char **bits
) { (void)CreateFromXpm(bits
); }
71 wxBitmap( char **bits
) { (void)CreateFromXpm((const char **)bits
); }
72 wxBitmap( const wxBitmap
& bmp
);
73 wxBitmap( const wxString
&filename
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
74 wxBitmap( const wxImage
& image
, int depth
= -1 ) { (void)CreateFromImage(image
, depth
); }
76 wxBitmap
& operator = ( const wxBitmap
& bmp
);
77 bool operator == ( const wxBitmap
& bmp
) const;
78 bool operator != ( const wxBitmap
& bmp
) const;
81 bool Create(int width
, int height
, int depth
= -1);
83 int GetHeight() const;
87 wxImage
ConvertToImage() const;
89 // copies the contents and mask of the given (colour) icon to the bitmap
90 virtual bool CopyFromIcon(const wxIcon
& icon
);
92 wxMask
*GetMask() const;
93 void SetMask( wxMask
*mask
);
95 wxBitmap
GetSubBitmap( const wxRect
& rect
) const;
97 bool SaveFile(const wxString
&name
, wxBitmapType type
,
98 const wxPalette
*palette
= (wxPalette
*)NULL
) const;
99 bool LoadFile(const wxString
&name
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
102 wxPalette
*GetPalette() const;
103 void SetPalette(const wxPalette
& palette
);
104 wxPalette
*GetColourMap() const { return GetPalette(); };
105 #endif // wxUSE_PALETTE
107 static void InitStandardHandlers();
112 void SetHeight( int height
);
113 void SetWidth( int width
);
114 void SetDepth( int depth
);
115 void SetPixmap( GdkPixmap
*pixmap
);
116 void SetBitmap( GdkBitmap
*bitmap
);
118 void SetPixbuf(GdkPixbuf
*pixbuf
);
121 GdkPixmap
*GetPixmap() const;
122 GdkBitmap
*GetBitmap() const;
123 bool HasPixmap() const;
125 bool HasPixbuf() const;
126 GdkPixbuf
*GetPixbuf() const;
129 // Basically, this corresponds to Win32 StretchBlt()
130 wxBitmap
Rescale( int clipx
, int clipy
, int clipwidth
, int clipheight
, int width
, int height
);
132 // raw bitmap access support functions
133 void *GetRawData(wxPixelDataBase
& data
, int bpp
);
134 void UngetRawData(wxPixelDataBase
& data
);
136 bool HasAlpha() const;
140 bool CreateFromXpm(const char **bits
);
141 bool CreateFromImage(const wxImage
& image
, int depth
);
144 // to be called from CreateFromImage only!
145 bool CreateFromImageAsBitmap(const wxImage
& image
);
146 bool CreateFromImageAsPixmap(const wxImage
& image
);
149 bool CreateFromImageAsPixbuf(const wxImage
& image
);
156 // removes other representations from memory, keeping only 'keep'
157 // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
158 void PurgeOtherRepresentations(Representation keep
);
160 friend class wxMemoryDC
;
162 friend class wxBitmapHandler
;
165 DECLARE_DYNAMIC_CLASS(wxBitmap
)
168 //-----------------------------------------------------------------------------
170 //-----------------------------------------------------------------------------
172 class WXDLLIMPEXP_CORE wxBitmapHandler
: public wxBitmapHandlerBase
175 wxBitmapHandler() { }
176 virtual ~wxBitmapHandler();
178 virtual bool Create(wxBitmap
*bitmap
, void *data
, long flags
, int width
, int height
, int depth
= 1);
179 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
180 int desiredWidth
, int desiredHeight
);
181 virtual bool SaveFile(const wxBitmap
*bitmap
, const wxString
& name
, int type
, const wxPalette
*palette
= NULL
);
184 DECLARE_DYNAMIC_CLASS(wxBitmapHandler
)
188 #endif // __GTKBITMAPH__