********* wx.Bitmap ********* Inheritance diagram for `wx.Bitmap`: | .. inheritance-diagram:: wx.Bitmap | Description =========== This class encapsulates the concept of a platform-dependent bitmap, either monochrome or colour or colour with alpha channel support. .. seealso:: `wx.DC.Blit `_ , `wx.Icon `_ , `wx.Cursor `_ , `wx.MemoryDC `_ Derived From ^^^^^^^^^^^^^ * `wx.GDIObject `_ * `wx.Object `_ Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `ConvertToImage <#ConvertToImage>`_ * `CopyFromBuffer <#CopyFromBuffer>`_ * `CopyFromBufferRGBA <#CopyFromBufferRGBA>`_ * `CopyFromCursor <#CopyFromCursor>`_ * `CopyFromIcon <#CopyFromIcon>`_ * `CopyToBuffer <#CopyToBuffer>`_ * `GetDepth <#GetDepth>`_ * `GetHandle <#GetHandle>`_ * `GetHeight <#GetHeight>`_ * `GetMask <#GetMask>`_ * `GetPalette <#GetPalette>`_ * `GetSize <#GetSize>`_ * `GetSubBitmap <#GetSubBitmap>`_ * `GetWidth <#GetWidth>`_ * `HasAlpha <#HasAlpha>`_ * `IsOk <#IsOk>`_ * `LoadFile <#LoadFile>`_ * `SaveFile <#SaveFile>`_ * `SetDepth <#SetDepth>`_ * `SetHandle <#SetHandle>`_ * `SetHeight <#SetHeight>`_ * `SetMask <#SetMask>`_ * `SetMaskColour <#SetMaskColour>`_ * `SetPalette <#SetPalette>`_ * `SetSize <#SetSize>`_ * `SetWidth <#SetWidth>`_ * `UseAlpha <#UseAlpha>`_ Properties Summary ^^^^^^^^^^^^^^^^^^ * `Depth <#Depth>`_ * `Height <#Height>`_ * `Mask <#Mask>`_ * `Palette <#Palette>`_ * `Size <#Size>`_ * `SubBitmap <#SubBitmap>`_ * `Width <#Width>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__(name, type=wx.BITMAP_TYPE_ANY) Loads a bitmap from a file. **Parameters:** * `name` (string) * `type` (int) | **Returns:** `wx.Bitmap `_ -------- .. method:: ConvertToImage() 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:** `wx.Image `_ -------- .. method:: CopyFromBuffer(data, format=wx.BitmapBufferFormat_RGB, stride=-1) 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: ============================= ================================ 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:** * `data` (buffer) * `format` (int) * `stride` (int) -------- .. method:: CopyFromBufferRGBA(buffer) Copy data from a RGBA buffer object to replace the bitmap pixel data. This method is now just a compatibility wrapper around `CopyFrombuffer <#CopyFromBuffer>`_. **Parameters:** * `buffer` -------- .. method:: CopyFromCursor(cursor) **Parameters:** * `cursor` (`wx.Cursor `_) | **Returns:** `bool` -------- .. method:: CopyFromIcon(icon) Creates the bitmap from an icon. **Parameters:** * `icon` (`wx.Icon `_) | **Returns:** `bool` -------- .. method:: CopyToBuffer(data, format=wx.BitmapBufferFormat_RGB, stride=-1) Copy pixel data to a buffer object. See `CopyFromBuffer <#CopyFromBuffer>`_ for buffer format. **Parameters:** * `data` (buffer) * `format` (int) * `stride` (int) -------- .. method:: GetDepth() Gets the colour depth of the bitmap. A value of 1 indicates a monochrome bitmap. | **Returns:** `int` -------- .. method:: GetHandle() `No docstrings available for this method.` -------- .. method:: GetHeight() Gets the height of the bitmap in pixels. | **Returns:** `int` -------- .. method:: GetMask() Gets the associated mask (if any) which may have been loaded from a file or set for the bitmap. | **Returns:** `wx.Mask `_ .. seealso:: `SetMask <#SetMask>`_, `wx.Mask `_ -------- .. method:: GetPalette() Gets the associated palette (if any) which may have been loaded from a file or set for the bitmap. | **Returns:** `wx.Palette `_ .. seealso:: `wx.Palette `_ -------- .. method:: GetSize() Get the size of the bitmap. | **Returns:** `wx.Size `_ -------- .. method:: GetSubBitmap(rect) 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:** * `rect` (`wx.Rect `_) | **Returns:** `wx.Bitmap `_ -------- .. method:: GetWidth() Gets the width of the bitmap in pixels. | **Returns:** `int` .. seealso:: `GetHeight <#GetHeight>`_ -------- .. method:: HasAlpha() Returns ``True`` if the bitmap has an alpha mask. -------- .. method:: IsOk() Returns ``True`` if bitmap data is present. | **Returns:** `bool` -------- .. method:: LoadFile(name, type) 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 <#GetPalette>`_ member. .. seealso:: `SaveFile <#SaveFile>`_ -------- .. method:: SaveFile(name, type, palette=None) 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. .. seealso:: `LoadFile <#LoadFile>`_ -------- .. method:: SetDepth(depth) Sets the depth member (does not affect the bitmap data). **Parameters:** * `depth` (int): Bitmap depth. -------- .. method:: SetHandle(handle) | **Parameters:** * `handle` (long) -------- .. method:: SetHeight(height) Sets the height member (does not affect the bitmap data). **Parameters:** * `height` (int): Bitmap height in pixels. -------- .. method:: SetMask(mask) Sets the mask for this bitmap. **Parameters:** * `mask` (`wx.Mask `_) .. note:: The bitmap object owns the mask once this has been called. .. seealso:: `GetMask <#GetMask>`_ , `wx.Mask `_ -------- .. method:: SetMaskColour(colour) Create a mask based on a specified colour in the Bitmap. **Parameters:** * `colour` (`wx.Colour `_) -------- .. method:: SetPalette(palette) Sets the associated palette. (Not implemented under GTK+). **Parameters:** * `palette` (`wx.Palette `_): The palette to set. .. seealso:: `wx.Palette `_ -------- .. method:: SetSize(size) Set the bitmap size (does not affect the existing bitmap data). **Parameters:** * `size` (`wx.Size `_) -------- .. method:: SetWidth(width) Sets the width member (does not affect the bitmap data). **Parameters:** * `width` (int): Bitmap width in pixels. -------- .. method:: UseAlpha() `No docstrings available for this method.` -------- Properties ^^^^^^^^^^ .. attribute:: Depth See `GetDepth <#GetDepth>`_ and `SetDepth <#SetDepth>`_ .. attribute:: Height See `GetHeight <#GetHeight>`_ and `SetHeight <#SetHeight>`_ .. attribute:: Mask See `GetMask <#GetMask>`_ and `SetMask <#SetMask>`_ .. attribute:: Palette See `GetPalette <#GetPalette>`_ .. attribute:: Size See `GetSize <#GetSize>`_ and `SetSize <#SetSize>`_ .. attribute:: SubBitmap See `GetSubBitmap <#GetSubBitmap>`_ .. attribute:: Width See `GetWidth <#GetWidth>`_ and `SetWidth <#SetWidth>`_