1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #ifndef __GTKBITMAPH__
12 #define __GTKBITMAPH__
14 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
19 #include "wx/object.h"
20 #include "wx/string.h"
21 #include "wx/palette.h"
22 #include "wx/gdiobj.h"
25 typedef struct _GdkPixbuf GdkPixbuf
;
28 class WXDLLEXPORT wxPixelDataBase
;
30 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
38 //-----------------------------------------------------------------------------
40 //-----------------------------------------------------------------------------
42 class wxMask
: public wxObject
46 wxMask( const wxBitmap
& bitmap
, const wxColour
& colour
);
47 wxMask( const wxBitmap
& bitmap
, int paletteIndex
);
48 wxMask( const wxBitmap
& bitmap
);
51 bool Create( const wxBitmap
& bitmap
, const wxColour
& colour
);
52 bool Create( const wxBitmap
& bitmap
, int paletteIndex
);
53 bool Create( const wxBitmap
& bitmap
);
58 GdkBitmap
*GetBitmap() const;
61 DECLARE_DYNAMIC_CLASS(wxMask
)
64 //-----------------------------------------------------------------------------
66 //-----------------------------------------------------------------------------
68 class wxBitmap
: public wxBitmapBase
72 wxBitmap( int width
, int height
, int depth
= -1 );
73 wxBitmap( const char bits
[], int width
, int height
, int depth
= 1 );
74 wxBitmap( const char **bits
) { (void)CreateFromXpm(bits
); }
75 wxBitmap( char **bits
) { (void)CreateFromXpm((const char **)bits
); }
76 wxBitmap( const wxBitmap
& bmp
);
77 wxBitmap( const wxString
&filename
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
78 wxBitmap( const wxImage
& image
, int depth
= -1 ) { (void)CreateFromImage(image
, depth
); }
80 wxBitmap
& operator = ( const wxBitmap
& bmp
);
81 bool operator == ( const wxBitmap
& bmp
) const;
82 bool operator != ( const wxBitmap
& bmp
) const;
85 bool Create(int width
, int height
, int depth
= -1);
87 int GetHeight() const;
91 wxImage
ConvertToImage() const;
93 // copies the contents and mask of the given (colour) icon to the bitmap
94 virtual bool CopyFromIcon(const wxIcon
& icon
);
96 wxMask
*GetMask() const;
97 void SetMask( wxMask
*mask
);
99 wxBitmap
GetSubBitmap( const wxRect
& rect
) const;
101 bool SaveFile(const wxString
&name
, wxBitmapType type
,
102 const wxPalette
*palette
= (wxPalette
*)NULL
) const;
103 bool LoadFile(const wxString
&name
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
106 wxPalette
*GetPalette() const;
107 void SetPalette(const wxPalette
& palette
);
108 wxPalette
*GetColourMap() const { return GetPalette(); };
109 #endif // wxUSE_PALETTE
111 static void InitStandardHandlers();
116 void SetHeight( int height
);
117 void SetWidth( int width
);
118 void SetDepth( int depth
);
119 void SetPixmap( GdkPixmap
*pixmap
);
120 void SetBitmap( GdkBitmap
*bitmap
);
122 void SetPixbuf(GdkPixbuf
*pixbuf
);
125 GdkPixmap
*GetPixmap() const;
126 GdkBitmap
*GetBitmap() const;
127 bool HasPixmap() const;
129 bool HasPixbuf() const;
130 GdkPixbuf
*GetPixbuf() const;
133 // Basically, this corresponds to Win32 StretchBlt()
134 wxBitmap
Rescale( int clipx
, int clipy
, int clipwidth
, int clipheight
, int width
, int height
);
136 // raw bitmap access support functions
137 void *GetRawData(wxPixelDataBase
& data
, int bpp
);
138 void UngetRawData(wxPixelDataBase
& data
);
140 bool HasAlpha() const;
144 bool CreateFromXpm(const char **bits
);
145 bool CreateFromImage(const wxImage
& image
, int depth
);
148 // to be called from CreateFromImage only!
149 bool CreateFromImageAsBitmap(const wxImage
& image
);
150 bool CreateFromImageAsPixmap(const wxImage
& image
);
153 bool CreateFromImageAsPixbuf(const wxImage
& image
);
160 // removes other representations from memory, keeping only 'keep'
161 // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
162 void PurgeOtherRepresentations(Representation keep
);
164 friend class wxMemoryDC
;
166 friend class wxBitmapHandler
;
169 DECLARE_DYNAMIC_CLASS(wxBitmap
)
172 //-----------------------------------------------------------------------------
174 //-----------------------------------------------------------------------------
176 class wxBitmapHandler
: public wxBitmapHandlerBase
179 wxBitmapHandler() { }
180 virtual ~wxBitmapHandler();
182 virtual bool Create(wxBitmap
*bitmap
, void *data
, long flags
, int width
, int height
, int depth
= 1);
183 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
184 int desiredWidth
, int desiredHeight
);
185 virtual bool SaveFile(const wxBitmap
*bitmap
, const wxString
& name
, int type
, const wxPalette
*palette
= NULL
);
188 DECLARE_DYNAMIC_CLASS(wxBitmapHandler
)
192 #endif // __GTKBITMAPH__