Version: 3.1.0
wxBitmapHandler Class Reference

#include <wx/bitmap.h>

+ Inheritance diagram for wxBitmapHandler:

Detailed Description

This is the base class for implementing bitmap file loading/saving, and bitmap creation from data.

It is used within wxBitmap and is not normally seen by the application.

If you wish to extend the capabilities of wxBitmap, derive a class from wxBitmapHandler and add the handler using wxBitmap::AddHandler() in your application initialization.

Note that all wxBitmapHandlers provided by wxWidgets are part of the wxCore library. For details about the default handlers, please see the note in the wxBitmap class documentation.

Library:  wxCore
Category:  Graphics Device Interface (GDI)
See Also
Bitmaps and Icons, wxBitmap, wxIcon, wxCursor

Public Member Functions

 wxBitmapHandler ()
 Default constructor.
 
virtual ~wxBitmapHandler ()
 Destroys the wxBitmapHandler object.
 
virtual bool Create (wxBitmap *bitmap, const void *data, wxBitmapType type, int width, int height, int depth=1)
 Creates a bitmap from the given data, which can be of arbitrary type.
 
const wxStringGetExtension () const
 Gets the file extension associated with this handler.
 
const wxStringGetName () const
 Gets the name of this handler.
 
wxBitmapType GetType () const
 Gets the bitmap type associated with this handler.
 
virtual bool LoadFile (wxBitmap *bitmap, const wxString &name, wxBitmapType type, int desiredWidth, int desiredHeight)
 Loads a bitmap from a file or resource, putting the resulting data into bitmap.
 
virtual bool SaveFile (const wxBitmap *bitmap, const wxString &name, wxBitmapType type, const wxPalette *palette=NULL) const
 Saves a bitmap in the named file.
 
void SetExtension (const wxString &extension)
 Sets the handler extension.
 
void SetName (const wxString &name)
 Sets the handler name.
 
void SetType (wxBitmapType type)
 Sets the handler type.
 
- Public Member Functions inherited from wxObject
 wxObject ()
 Default ctor; initializes to NULL the internal reference data.
 
 wxObject (const wxObject &other)
 Copy ctor.
 
virtual ~wxObject ()
 Destructor.
 
virtual wxClassInfoGetClassInfo () const
 This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar).
 
wxObjectRefDataGetRefData () const
 Returns the wxObject::m_refData pointer, i.e. the data referenced by this object.
 
bool IsKindOf (const wxClassInfo *info) const
 Determines whether this class is a subclass of (or the same class as) the given class.
 
bool IsSameAs (const wxObject &obj) const
 Returns true if this object has the same data pointer as obj.
 
void Ref (const wxObject &clone)
 Makes this object refer to the data in clone.
 
void SetRefData (wxObjectRefData *data)
 Sets the wxObject::m_refData pointer.
 
void UnRef ()
 Decrements the reference count in the associated data, and if it is zero, deletes the data.
 
void UnShare ()
 This is the same of AllocExclusive() but this method is public.
 
void operator delete (void *buf)
 The delete operator is defined for debugging versions of the library only, when the identifier WXDEBUG is defined.
 
void * operator new (size_t size, const wxString &filename=NULL, int lineNum=0)
 The new operator is defined for debugging versions of the library only, when the identifier WXDEBUG is defined.
 

Additional Inherited Members

- Protected Member Functions inherited from wxObject
void AllocExclusive ()
 Ensure that this object's data is not shared with any other object.
 
virtual wxObjectRefDataCreateRefData () const
 Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it.
 
virtual wxObjectRefDataCloneRefData (const wxObjectRefData *data) const
 Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data.
 
- Protected Attributes inherited from wxObject
wxObjectRefDatam_refData
 Pointer to an object which is the object's reference-counted data.
 

Constructor & Destructor Documentation

wxBitmapHandler::wxBitmapHandler ( )

Default constructor.

In your own default constructor, initialise the members m_name, m_extension and m_type.

virtual wxBitmapHandler::~wxBitmapHandler ( )
virtual

Destroys the wxBitmapHandler object.

Member Function Documentation

virtual bool wxBitmapHandler::Create ( wxBitmap bitmap,
const void *  data,
wxBitmapType  type,
int  width,
int  height,
int  depth = 1 
)
virtual

Creates a bitmap from the given data, which can be of arbitrary type.

The wxBitmap object bitmap is manipulated by this function.

Parameters
bitmapThe wxBitmap object.
widthThe width of the bitmap in pixels.
heightThe height of the bitmap in pixels.
depthThe depth of the bitmap in pixels. If this is wxBITMAP_SCREEN_DEPTH, the screen depth is used.
dataData whose type depends on the value of type.
typeA bitmap type identifier - see wxBitmapType for a list of possible values.
Returns
true if the call succeeded, false otherwise (the default).
const wxString& wxBitmapHandler::GetExtension ( ) const

Gets the file extension associated with this handler.

const wxString& wxBitmapHandler::GetName ( ) const

Gets the name of this handler.

wxBitmapType wxBitmapHandler::GetType ( ) const

Gets the bitmap type associated with this handler.

virtual bool wxBitmapHandler::LoadFile ( wxBitmap bitmap,
const wxString name,
wxBitmapType  type,
int  desiredWidth,
int  desiredHeight 
)
virtual

Loads a bitmap from a file or resource, putting the resulting data into bitmap.

Note
Under MSW, when loading a bitmap from resources (i.e. using wxBITMAP_TYPE_BMP_RESOURCE as type), the light grey colour is considered to be transparent, for historical reasons. If you want to handle the light grey pixels normally instead, call SetMask(NULL) after loading the bitmap.
Parameters
bitmapThe bitmap object which is to be affected by this operation.
nameEither a filename or a Windows resource name. The meaning of name is determined by the type parameter.
typeSee wxBitmapType for values this can take.
desiredWidthThe desired width for the loaded bitmap.
desiredHeightThe desired height for the loaded bitmap.
Returns
true if the operation succeeded, false otherwise.
See Also
wxBitmap::LoadFile, wxBitmap::SaveFile, SaveFile()
virtual bool wxBitmapHandler::SaveFile ( const wxBitmap bitmap,
const wxString name,
wxBitmapType  type,
const wxPalette palette = NULL 
) const
virtual

Saves a bitmap in the named file.

Parameters
bitmapThe bitmap object which is to be affected by this operation.
nameA filename. The meaning of name is determined by the type parameter.
typeSee wxBitmapType for values this can take.
paletteAn optional palette used for saving the bitmap.
Returns
true if the operation succeeded, false otherwise.
See Also
wxBitmap::LoadFile, wxBitmap::SaveFile, LoadFile()
void wxBitmapHandler::SetExtension ( const wxString extension)

Sets the handler extension.

Parameters
extensionHandler extension.
void wxBitmapHandler::SetName ( const wxString name)

Sets the handler name.

Parameters
nameHandler name.
void wxBitmapHandler::SetType ( wxBitmapType  type)

Sets the handler type.

Parameters
typeHandler type.