Package wx :: Class Bitmap
[frames | no frames]

Type Bitmap

object --+        
         |        
    Object --+    
             |    
     GDIObject --+
                 |
                Bitmap


The wx.Bitmap class encapsulates the concept of a platform-dependent bitmap. It can be either monochrome or colour, and either loaded from a file or created dynamically. A bitmap can be selected into a memory device context (instance of wx.MemoryDC). This enables the bitmap to be copied to a window or memory device context using wx.DC.Blit, or to be used as a drawing surface.

The BMP and XMP image file formats are supported on all platforms by wx.Bitmap. Other formats are automatically loaded by wx.Image and converted to a wx.Bitmap, so any image file format supported by wx.Image can be used.


See Also:

wx.EmptyBitmap, wx.BitmapFromIcon, wx.BitmapFromImage, wx.BitmapFromXPMData, wx.BitmapFromBits, wx.BitmapFromBuffer, wx.BitmapFromBufferRGBA, wx.Image

To Do:

Method Summary
Bitmap __init__(self, name, type)
  __del__(self)
bool __eq__(self, other)
bool __ne__(self, other)
  __nonzero__(self)
Image ConvertToImage(self)
Creates a platform-independent image from a platform-dependent bitmap.
  CopyFromBuffer(self, data)
Copy data from a RGB buffer object to replace the bitmap pixel data.
  CopyFromBufferRGBA(self, data)
Copy data from a RGBA buffer object to replace the bitmap pixel data.
bool CopyFromIcon(self, icon)
int GetDepth(self)
Gets the colour depth of the bitmap.
int GetHeight(self)
Gets the height of the bitmap in pixels.
Mask GetMask(self)
Gets the associated mask (if any) which may have been loaded from a file or explpicitly set for the bitmap.
Palette GetPalette(self)
Size GetSize(self)
Get the size of the bitmap.
Bitmap GetSubBitmap(self, rect)
Returns a sub-bitmap of the current one as long as the rect belongs entirely to the bitmap.
int GetWidth(self)
Gets the width of the bitmap in pixels.
bool IsOk(self)
bool LoadFile(self, name, type)
Loads a bitmap from a file.
bool Ok(self)
bool SaveFile(self, name, type, palette)
Saves a bitmap in the named file.
  SetDepth(self, depth)
Set the depth property (does not affect the existing bitmap data).
  SetHeight(self, height)
Set the height property (does not affect the existing bitmap data).
  SetMask(self, mask)
Sets the mask for this bitmap.
  SetMaskColour(self, colour)
Create a Mask based on a specified colour in the Bitmap.
  SetSize(self, size)
Set the bitmap size (does not affect the existing bitmap data).
  SetWidth(self, width)
Set the width property (does not affect the existing bitmap data).

Property Summary
  Depth: See GetDepth and SetDepth
  Height: See GetHeight and SetHeight
  Mask: See GetMask and SetMask
  Palette: See GetPalette
  Size: See GetSize and SetSize
  SubBitmap: See GetSubBitmap
  thisown: The membership flag
  Width: See GetWidth and SetWidth

Method Details

__init__(self, name, type=BITMAP_TYPE_ANY)
(Constructor)

Loads a bitmap from a file.
Parameters:
name - Name of the file to load the bitmap from.
           (type=String)

type - The type of image to expect. Can be one of the following constants (assuming that the neccessary wx.Image handlers are loaded):

  • wx.BITMAP_TYPE_ANY
  • wx.BITMAP_TYPE_BMP
  • wx.BITMAP_TYPE_ICO
  • wx.BITMAP_TYPE_CUR
  • wx.BITMAP_TYPE_XBM
  • wx.BITMAP_TYPE_XPM
  • wx.BITMAP_TYPE_TIF
  • wx.BITMAP_TYPE_GIF
  • wx.BITMAP_TYPE_PNG
  • wx.BITMAP_TYPE_JPEG
  • wx.BITMAP_TYPE_PNM
  • wx.BITMAP_TYPE_PCX
  • wx.BITMAP_TYPE_PICT
  • wx.BITMAP_TYPE_ICON
  • wx.BITMAP_TYPE_ANI
  • wx.BITMAP_TYPE_IFF

           (type=int)

Returns:
Bitmap
Overrides:
wx.GDIObject.__init__

See Also:

Alternate constructors wx.EmptyBitmap, wx.BitmapFromIcon, wx.BitmapFromImage, wx.BitmapFromXPMData, wx.BitmapFromBits, wx.BitmapFromBuffer, wx.BitmapFromBufferRGBA,

ConvertToImage(self)

Creates a platform-independent 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:
Image

CopyFromBuffer(self, data)

Copy data from a RGB buffer object to replace the bitmap pixel data. See wx.BitmapFromBuffer for more .

Parameters:
data
           (type=buffer)

CopyFromBufferRGBA(self, data)

Copy data from a RGBA buffer object to replace the bitmap pixel data. See wx.BitmapFromBufferRGBA for more .

Parameters:
data
           (type=buffer)

GetDepth(self)

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

Returns:
int

GetHeight(self)

Gets the height of the bitmap in pixels.

Returns:
int

GetMask(self)

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

Returns:
Mask

See Also:

SetMask, wx.Mask

GetSize(self)

Get the size of the bitmap.

Returns:
Size

GetSubBitmap(self, 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
           (type=Rect)

Returns:
Bitmap

GetWidth(self)

Gets the width of the bitmap in pixels.

Returns:
int

LoadFile(self, name, type)

Loads a bitmap from a file. See __init__ for a description of the type parameter.

Parameters:
name
           (type=String)

type
           (type=int)

Returns:
bool

SaveFile(self, name, type, palette=None)

Saves a bitmap in the named file. See __init__ for a description of the type parameter.

Parameters:
name
           (type=String)

type
           (type=int)

palette
           (type=Palette)

Returns:
bool

SetDepth(self, depth)

Set the depth property (does not affect the existing bitmap data).

Parameters:
depth
           (type=int)

SetHeight(self, height)

Set the height property (does not affect the existing bitmap data).

Parameters:
height
           (type=int)

SetMask(self, mask)

Sets the mask for this bitmap.

Parameters:
mask
           (type=Mask)

See Also:

GetMask, wx.Mask

SetMaskColour(self, colour)

Create a Mask based on a specified colour in the Bitmap.

Parameters:
colour
           (type=Colour)

SetSize(self, size)

Set the bitmap size (does not affect the existing bitmap data).

Parameters:
size
           (type=Size)

SetWidth(self, width)

Set the width property (does not affect the existing bitmap data).

Parameters:
width
           (type=int)


Property Details

Depth

See GetDepth and SetDepth

Get Method:
GetDepth(self)
Set Method:
SetDepth(self, depth)

Height

See GetHeight and SetHeight

Get Method:
GetHeight(self)
Set Method:
SetHeight(self, height)

Mask

See GetMask and SetMask

Get Method:
GetMask(self)
Set Method:
SetMask(self, mask)

Palette

See GetPalette

Get Method:
GetPalette(self)

Size

See GetSize and SetSize

Get Method:
GetSize(self)
Set Method:
SetSize(self, size)

SubBitmap

See GetSubBitmap

Get Method:
GetSubBitmap(self, rect)

thisown

The membership flag

Width

See GetWidth and SetWidth

Get Method:
GetWidth(self)
Set Method:
SetWidth(self, width)

Generated by Epydoc 2.1.20050511.rpd on Thu Mar 22 12:07:26 2007 http://epydoc.sf.net