1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: bitmap.h
|
|
|
|
// Purpose:
|
|
|
|
// Author: Robert Roebling
|
1998-05-28 15:54:07 -04:00
|
|
|
// RCS-ID: $Id$
|
1998-10-24 13:12:05 -04:00
|
|
|
// Copyright: (c) 1998 Robert Roebling
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __GTKBITMAPH__
|
|
|
|
#define __GTKBITMAPH__
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
|
|
|
#include "wx/palette.h"
|
1999-12-04 05:37:39 -05:00
|
|
|
#include "wx/gdiobj.h"
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2004-08-21 18:42:06 -04:00
|
|
|
#ifdef __WXGTK20__
|
|
|
|
typedef struct _GdkPixbuf GdkPixbuf;
|
|
|
|
#endif
|
|
|
|
|
2005-02-13 12:14:19 -05:00
|
|
|
class WXDLLEXPORT wxPixelDataBase;
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// classes
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2005-08-02 18:58:06 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxMask;
|
|
|
|
class WXDLLIMPEXP_CORE wxBitmap;
|
|
|
|
class WXDLLIMPEXP_CORE wxImage;
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxMask
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2005-08-02 18:58:06 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxMask: public wxObject
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
1998-11-06 03:50:52 -05:00
|
|
|
public:
|
1999-08-24 16:26:06 -04:00
|
|
|
wxMask();
|
|
|
|
wxMask( const wxBitmap& bitmap, const wxColour& colour );
|
|
|
|
wxMask( const wxBitmap& bitmap, int paletteIndex );
|
|
|
|
wxMask( const wxBitmap& bitmap );
|
|
|
|
~wxMask();
|
1999-06-13 11:24:01 -04:00
|
|
|
|
1999-08-24 16:26:06 -04:00
|
|
|
bool Create( const wxBitmap& bitmap, const wxColour& colour );
|
|
|
|
bool Create( const wxBitmap& bitmap, int paletteIndex );
|
|
|
|
bool Create( const wxBitmap& bitmap );
|
|
|
|
|
|
|
|
// implementation
|
|
|
|
GdkBitmap *m_bitmap;
|
|
|
|
|
|
|
|
GdkBitmap *GetBitmap() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxMask)
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxBitmap
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2005-08-02 18:58:06 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
1998-11-06 03:50:52 -05:00
|
|
|
public:
|
1999-08-24 16:26:06 -04:00
|
|
|
wxBitmap();
|
|
|
|
wxBitmap( int width, int height, int depth = -1 );
|
|
|
|
wxBitmap( const char bits[], int width, int height, int depth = 1 );
|
1999-12-16 14:36:05 -05:00
|
|
|
wxBitmap( const char **bits ) { (void)CreateFromXpm(bits); }
|
|
|
|
wxBitmap( char **bits ) { (void)CreateFromXpm((const char **)bits); }
|
1999-08-24 16:26:06 -04:00
|
|
|
wxBitmap( const wxBitmap& bmp );
|
2005-02-05 08:08:44 -05:00
|
|
|
wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM );
|
2001-04-04 19:15:36 -04:00
|
|
|
wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
|
1999-08-24 16:26:06 -04:00
|
|
|
~wxBitmap();
|
|
|
|
wxBitmap& operator = ( const wxBitmap& bmp );
|
2000-07-15 15:51:35 -04:00
|
|
|
bool operator == ( const wxBitmap& bmp ) const;
|
|
|
|
bool operator != ( const wxBitmap& bmp ) const;
|
1999-08-24 16:26:06 -04:00
|
|
|
bool Ok() const;
|
|
|
|
|
2000-02-27 11:48:27 -05:00
|
|
|
bool Create(int width, int height, int depth = -1);
|
|
|
|
|
1999-08-24 16:26:06 -04:00
|
|
|
int GetHeight() const;
|
|
|
|
int GetWidth() const;
|
|
|
|
int GetDepth() const;
|
2001-04-04 19:15:36 -04:00
|
|
|
|
|
|
|
wxImage ConvertToImage() const;
|
1999-08-24 16:26:06 -04:00
|
|
|
|
2001-09-23 18:36:17 -04:00
|
|
|
// copies the contents and mask of the given (colour) icon to the bitmap
|
|
|
|
virtual bool CopyFromIcon(const wxIcon& icon);
|
|
|
|
|
1999-08-24 16:26:06 -04:00
|
|
|
wxMask *GetMask() const;
|
|
|
|
void SetMask( wxMask *mask );
|
1999-12-23 13:18:43 -05:00
|
|
|
|
|
|
|
wxBitmap GetSubBitmap( const wxRect& rect ) const;
|
1999-08-24 16:26:06 -04:00
|
|
|
|
2005-02-05 08:08:44 -05:00
|
|
|
bool SaveFile(const wxString &name, wxBitmapType type,
|
|
|
|
const wxPalette *palette = (wxPalette *)NULL) const;
|
|
|
|
bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_TYPE_XPM );
|
1999-08-24 16:26:06 -04:00
|
|
|
|
2005-02-05 08:08:44 -05:00
|
|
|
#if wxUSE_PALETTE
|
1999-08-24 16:26:06 -04:00
|
|
|
wxPalette *GetPalette() const;
|
2005-02-05 08:08:44 -05:00
|
|
|
void SetPalette(const wxPalette& palette);
|
2003-06-30 16:11:23 -04:00
|
|
|
wxPalette *GetColourMap() const { return GetPalette(); };
|
2005-02-05 08:08:44 -05:00
|
|
|
#endif // wxUSE_PALETTE
|
2003-06-30 16:11:23 -04:00
|
|
|
|
2005-02-05 09:17:27 -05:00
|
|
|
static void InitStandardHandlers();
|
1998-12-09 12:30:17 -05:00
|
|
|
|
1999-08-24 16:26:06 -04:00
|
|
|
// implementation
|
1999-11-22 14:44:25 -05:00
|
|
|
// --------------
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-08-24 16:26:06 -04:00
|
|
|
void SetHeight( int height );
|
|
|
|
void SetWidth( int width );
|
|
|
|
void SetDepth( int depth );
|
|
|
|
void SetPixmap( GdkPixmap *pixmap );
|
2000-01-12 12:57:18 -05:00
|
|
|
void SetBitmap( GdkBitmap *bitmap );
|
2004-08-21 18:42:06 -04:00
|
|
|
#ifdef __WXGTK20__
|
|
|
|
void SetPixbuf(GdkPixbuf *pixbuf);
|
|
|
|
#endif
|
1998-12-09 12:30:17 -05:00
|
|
|
|
1999-08-24 16:26:06 -04:00
|
|
|
GdkPixmap *GetPixmap() const;
|
|
|
|
GdkBitmap *GetBitmap() const;
|
2004-08-21 18:42:06 -04:00
|
|
|
bool HasPixmap() const;
|
|
|
|
#ifdef __WXGTK20__
|
|
|
|
bool HasPixbuf() const;
|
|
|
|
GdkPixbuf *GetPixbuf() const;
|
|
|
|
#endif
|
1999-08-24 16:26:06 -04:00
|
|
|
|
2003-10-09 16:01:49 -04:00
|
|
|
// Basically, this corresponds to Win32 StretchBlt()
|
|
|
|
wxBitmap Rescale( int clipx, int clipy, int clipwidth, int clipheight, int width, int height );
|
2005-02-13 10:35:43 -05:00
|
|
|
|
|
|
|
// raw bitmap access support functions
|
|
|
|
void *GetRawData(wxPixelDataBase& data, int bpp);
|
|
|
|
void UngetRawData(wxPixelDataBase& data);
|
|
|
|
|
2005-02-15 15:27:46 -05:00
|
|
|
bool HasAlpha() const;
|
|
|
|
void UseAlpha();
|
2005-02-13 12:16:33 -05:00
|
|
|
|
1999-12-16 14:36:05 -05:00
|
|
|
protected:
|
|
|
|
bool CreateFromXpm(const char **bits);
|
2001-04-04 19:15:36 -04:00
|
|
|
bool CreateFromImage(const wxImage& image, int depth);
|
1999-12-16 14:36:05 -05:00
|
|
|
|
1999-08-24 16:26:06 -04:00
|
|
|
private:
|
2004-08-21 18:42:06 -04:00
|
|
|
// to be called from CreateFromImage only!
|
|
|
|
bool CreateFromImageAsBitmap(const wxImage& image);
|
|
|
|
bool CreateFromImageAsPixmap(const wxImage& image);
|
|
|
|
|
|
|
|
#ifdef __WXGTK20__
|
|
|
|
bool CreateFromImageAsPixbuf(const wxImage& image);
|
|
|
|
|
|
|
|
enum Representation
|
|
|
|
{
|
|
|
|
Pixmap,
|
|
|
|
Pixbuf
|
|
|
|
};
|
|
|
|
// removes other representations from memory, keeping only 'keep'
|
|
|
|
// (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
|
|
|
|
void PurgeOtherRepresentations(Representation keep);
|
|
|
|
|
|
|
|
friend class wxMemoryDC;
|
|
|
|
#endif
|
2005-02-05 09:17:27 -05:00
|
|
|
friend class wxBitmapHandler;
|
|
|
|
|
|
|
|
private:
|
1999-08-24 16:26:06 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
2005-02-05 09:17:27 -05:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxBitmapHandler
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2005-08-02 18:58:06 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase
|
2005-02-05 09:17:27 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxBitmapHandler() { }
|
|
|
|
virtual ~wxBitmapHandler();
|
|
|
|
|
|
|
|
virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
|
|
|
|
virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
|
|
|
int desiredWidth, int desiredHeight);
|
|
|
|
virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif // __GTKBITMAPH__
|