Contents Up Previous Next

wxBitmap: wxObject

Overview

This class encapsulates the concept of a platform-dependent bitmap, either monochrome or colour.

wxBitmap::wxBitmap
wxBitmap::~wxBitmap
wxBitmap::Create
wxBitmap::GetColourMap
wxBitmap::GetDepth
wxBitmap::GetHeight
wxBitmap::GetWidth
wxBitmap::LoadFile
wxBitmap::Ok
wxBitmap::SaveFile
wxBitmap::SetColourMap


wxBitmap::wxBitmap

void wxBitmap(char bits[], int width, int height
int depth = 1)

Constructs a (usually monochrome) bitmap from an array of pixel values, under both X and Windows.

void wxBitmap(int width, int height int depth = -1)

Constructs a new bitmap. If the final argument is omitted, the display depth of the screen is used.

void wxBitmap(char **bits)

Constructs a bitmap from pixmap (XPM) data, if wxWindows has been configured to incorporate this feature.

To use this constructor, you must first include an XPM file. For example, assuming that the file mybitmap.xpm contains an XPM array of character pointers called mybitmap:

#include "mybitmap.xpm"

...

wxBitmap *bitmap = new wxBitmap(mybitmap);
void wxBitmap(char *name, long flags)

Constructs a bitmap from a file or resource. name can refer to a resource name under MS Windows, or a filename under MS Windows and X.

Under Windows, flags defaults to wxBITMAP_TYPE_BMP_RESOURCE | wxBITMAP_DISCARD_COLOURMAP. Under X, flags defaults to wxBITMAP_TYPE_XBM | wxBITMAP_DISCARD_COLOURMAP.

The meaning of name is determined by the flags parameter which may be a bit list of wxBITMAP_DISCARD_COLOURMAP (meaning the colourmap read, if any, should be thrown away) and one of:

wxBITMAP_TYPE_BMP Load a Windows bitmap file.
wxBITMAP_TYPE_BMP_RESOURCE Load a Windows bitmap from the resource database.
wxBITMAP_TYPE_GIF Load a GIF bitmap file.
wxBITMAP_TYPE_XBM Load an X bitmap file.
wxBITMAP_TYPE_XPM Load an XPM bitmap file.
wxBITMAP_TYPE_RESOURCE Load a Windows resource name.

The validity of these flags depends on the platform and wxWindows configuration. If all possible wxWindows settings are used, the Windows platform supports BMP, BMP_RESOURCE, XPM_DATA, and XPM. Under X, the available formats are BMP, GIF, XBM, and XPM.


wxBitmap::~wxBitmap

void ~wxBitmap(void)

Destroys the bitmap. The bitmap will be destroyed automatically by wxWindows when the application exits.


wxBitmap::Create

void Create(int width, int height int depth = -1)

Creates a new bitmap. If the final argument is omitted, the display depth of the screen is used.


wxBitmap::GetColourMap

wxColourMap * GetColourMap(void)

Gets the associated colourmap (if any) which may have been loaded from a file or set for the bitmap.


wxBitmap::GetDepth

int GetDepth(void)

Gets the colour depth of the bitmap. A value of 1 indicates a monochrome bitmap.


wxBitmap::GetHeight

int GetHeight(void)

Gets the height of the bitmap in pixels.


wxBitmap::GetWidth

int GetWidth(void)

Gets the width of the bitmap in pixels.


wxBitmap::LoadFile

Bool LoadFile(char *name, long flags)

Loads a bitmap from a file or resource. name can refer to a resource name under MS Windows, or a filename under MS Windows and X.

The meaning of name is determined by the flags parameter which may be a bit list of wxBITMAP_DISCARD_COLOURMAP (meaning the colourmap read, if any, should be thrown away) and one of:

wxBITMAP_TYPE_BMP Load a Windows bitmap file.
wxBITMAP_TYPE_BMP_RESOURCE Load a Windows bitmap from the resource database.
wxBITMAP_TYPE_GIF Load a GIF bitmap file.
wxBITMAP_TYPE_XBM Load an X bitmap file.
wxBITMAP_TYPE_XPM Load an XPM bitmap file.
wxBITMAP_TYPE_RESOURCE Load a Windows resource name.

The validity of these flags depends on the platform and wxWindows configuration.

A colourmap may be associated with the bitmap if one exists (especially for colour Windows bitmaps), and if the code supports it. You can check if one has been created by using the GetColourMap member.


wxBitmap::Ok

Bool Ok(void)

Returns TRUE if the bitmap was successfully created.


wxBitmap::SaveFile

Bool SaveFile(char *name, int type, wxColourMap *cmap)

Saves a bitmap in the named file.

The type of saved is determined by the type parameter which may be one of:

wxBITMAP_TYPE_BMP Save a Windows bitmap file.
wxBITMAP_TYPE_GIF Save a GIF bitmap file.
wxBITMAP_TYPE_XBM Save an X bitmap file.
wxBITMAP_TYPE_XPM Save an XPM bitmap file.

The validity of these flags depends on the platform and wxWindows configuration.

If a colourmap is supplied, it may be used when saving the bitmap. If this parameter is NULL and there is a colourmap associated with the bitmap, this internal colourmap may be used instead.


wxBitmap::SetColourMap

void SetColourMap(wxColourMap *cmap)

Sets the associated colourmap: it will be deleted in the wxBitmap destructor, so if you do not wish it to be deleted automatically, reset the colourmap to NULL before the bitmap is deleted.