Inheritance diagram for wx.Bitmap:
This class encapsulates the concept of a platform-dependent bitmap, either monochrome or colour or colour with alpha channel support.
See also
Loads a bitmap from a file.
Alternative constructors supported by wxPython are:
Alternative Constructors | Description |
---|---|
wx.EmptyBitmap (width, height, depth=-1) | Creates an empty bitmap with the given specifications. |
wx.BitmapFromXPMData (listOfStrings) | Create a bitmap from a Python list of strings whose contents are XPM data. |
wx.BitmapFromBits (bits, width, height, depth=-1) | Create a bitmap from an array of bits contained in a string. |
wx.BitmapFromImage (image, depth=-1) | Convert a wx.Image to a wx.Bitmap. |
wx.BitmapFromBuffer (width, height, dataBuffer, alphaBuffer=None) | Creates a wx.Bitmap from the data in dataBuffer. |
wx.BitmapFromBufferRGBA (width, height, dataBuffer) | Creates a wx.Bitmap from the data in dataBuffer. |
wx.BitmapFromIcon (icon) | Creates a wx.Bitmap from a wx.Icon object. |
Parameters:
Returns:
Creates an image from a platform-dependent bitmap. This preserves mask information so that bitmaps and images can be converted back and forth without loss in that respect.
Returns:
Copy data from a buffer object to replace the bitmap pixel data. Default format is plain RGB, but other formats are now supported as well.
The following symbols are used to specify the format of the bytes in the buffer:
Format Flag | Description |
---|---|
wx.BitmapBufferFormat_RGB | A simple sequence of RGB bytes |
wx.BitmapBufferFormat_RGBA | A simple sequence of RGBA bytes |
wx.BitmapBufferFormat_ARGB32 | A sequence of 32-bit values in native endian order, with alpha in the upper 8 bits, followed by red, green, and blue. |
wx.BitmapBufferFormat_RGB32 | Same as above but the alpha byte is ignored. |
Parameters:
Copy data from a RGBA buffer object to replace the bitmap pixel data. This method is now just a compatibility wrapper around CopyFrombuffer.
Parameters:
Copy pixel data to a buffer object. See CopyFromBuffer for buffer format.
Parameters:
Gets the colour depth of the bitmap. A value of 1 indicates a monochrome bitmap.
Returns:
int
Gets the height of the bitmap in pixels.
Returns:
int
Gets the associated mask (if any) which may have been loaded from a file or set for the bitmap.
Returns:
Gets the associated palette (if any) which may have been loaded from a file or set for the bitmap.
Returns:
See also
Returns a sub bitmap of the current one as long as the rect belongs entirely to the bitmap.
This function preserves bit depth and mask information.
Parameters:
Returns:
Gets the width of the bitmap in pixels.
Returns:
int
See also
Returns True if bitmap data is present.
Returns:
bool
Loads a bitmap from a file or resource.
Parameters:
name (string): Either a filename or a Windows resource name. The meaning of name is determined by the type parameter.
type (int): One of the following values:
wx.BITMAP_TYPE_BMP |
Load a Windows bitmap file. |
wx.BITMAP_TYPE_BMP_RESOURCE |
Load a Windows bitmap resource from the executable. |
wx.BITMAP_TYPE_PICT_RESOURCE |
Load a PICT image resource from the executable. Mac OS only. |
wx.BITMAP_TYPE_GIF |
Load a GIF bitmap file. |
wx.BITMAP_TYPE_XBM |
Load an X bitmap file. |
wx.BITMAP_TYPE_XPM |
Load an XPM bitmap file. |
The validity of these flags depends on the platform and wxWidgets configuration.
In addition, wx.Bitmap can read all formats that wx.Image can (wx.BITMAP_TYPE_JPEG, wx.BITMAP_TYPE_PNG, wx.BITMAP_TYPE_GIF, wx.BITMAP_TYPE_PCX, wx.BITMAP_TYPE_PNM).
Returns:
bool
Note
A palette 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 GetPalette member.
See also
Saves a bitmap in the named file.
Parameters:
name (string): A filename. The meaning of name is determined by the type parameter.
type (int): One of the following values:
wx.BITMAP_TYPE_BMP |
Save a Windows bitmap file. |
wx.BITMAP_TYPE_GIF |
Save a GIF bitmap file. |
wx.BITMAP_TYPE_XBM |
Save an X bitmap file. |
wx.BITMAP_TYPE_XPM |
Save an XPM bitmap file. |
In addition, wx.Bitmap can read all formats that wx.Image can (i.e., wx.BITMAP_TYPE_JPEG, wx.BITMAP_TYPE_PNG, wx.BITMAP_TYPE_GIF, wx.BITMAP_TYPE_PCX, wx.BITMAP_TYPE_PNM).
palette (wx.Palette): An optional palette used for saving the bitmap.
Returns:
bool
Note
Depending on how wxWidgets has been configured, not all formats may be available.
See also
Sets the depth member (does not affect the bitmap data).
Parameters:
Parameters:
Sets the height member (does not affect the bitmap data).
Parameters:
Note
The bitmap object owns the mask once this has been called.
Create a mask based on a specified colour in the Bitmap.
Parameters:
Sets the associated palette. (Not implemented under GTK+).
Parameters:
See also
Set the bitmap size (does not affect the existing bitmap data).
Parameters:
Sets the width member (does not affect the bitmap data).
Parameters: