2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: bitmap.h
|
2008-03-15 14:15:46 -04:00
|
|
|
// Purpose: interface of wxBitmap* classes
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-03-16 20:47:38 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
In wxBitmap and wxBitmapHandler context this value means: "use the screen depth".
|
|
|
|
*/
|
|
|
|
#define wxBITMAP_SCREEN_DEPTH (-1)
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxBitmapHandler
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-15 14:15:46 -04:00
|
|
|
This is the base class for implementing bitmap file loading/saving, and
|
|
|
|
bitmap creation from data.
|
2008-03-08 08:52:38 -05:00
|
|
|
It is used within wxBitmap and is not normally seen by the application.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
If you wish to extend the capabilities of wxBitmap, derive a class from
|
2008-03-25 18:06:48 -04:00
|
|
|
wxBitmapHandler and add the handler using wxBitmap::AddHandler() in your
|
2009-03-03 18:10:13 -05:00
|
|
|
application initialization.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-15 11:36:15 -04:00
|
|
|
Note that all wxBitmapHandlers provided by wxWidgets are part of the
|
|
|
|
@ref page_libs_wxcore library.
|
|
|
|
For details about the default handlers, please see the note in the
|
|
|
|
wxBitmap class documentation.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
2009-02-20 06:34:52 -05:00
|
|
|
@category{gdi}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-15 14:15:46 -04:00
|
|
|
@see @ref overview_bitmap, wxBitmap, wxIcon, wxCursor
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxBitmapHandler : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-03-15 14:15:46 -04:00
|
|
|
Default constructor.
|
|
|
|
|
|
|
|
In your own default constructor, initialise the members m_name,
|
|
|
|
m_extension and m_type.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxBitmapHandler();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destroys the wxBitmapHandler object.
|
|
|
|
*/
|
2008-03-24 18:17:25 -04:00
|
|
|
virtual ~wxBitmapHandler();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-15 14:15:46 -04:00
|
|
|
Creates a bitmap from the given data, which can be of arbitrary type.
|
|
|
|
The wxBitmap object @a bitmap is manipulated by this function.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bitmap
|
2008-03-09 08:33:59 -04:00
|
|
|
The wxBitmap object.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param width
|
2008-03-09 08:33:59 -04:00
|
|
|
The width of the bitmap in pixels.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param height
|
2008-03-09 08:33:59 -04:00
|
|
|
The height of the bitmap in pixels.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param depth
|
2008-03-16 20:47:38 -04:00
|
|
|
The depth of the bitmap in pixels.
|
|
|
|
If this is ::wxBITMAP_SCREEN_DEPTH, the screen depth is used.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param data
|
2008-03-09 08:33:59 -04:00
|
|
|
Data whose type depends on the value of type.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param type
|
2008-03-15 14:15:46 -04:00
|
|
|
A bitmap type identifier - see ::wxBitmapType for a list
|
2008-03-09 08:33:59 -04:00
|
|
|
of possible values.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the call succeeded, @false otherwise (the default).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-16 20:47:38 -04:00
|
|
|
virtual bool Create(wxBitmap* bitmap, const void* data, wxBitmapType type,
|
2008-03-25 18:06:48 -04:00
|
|
|
int width, int height, int depth = 1);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the file extension associated with this handler.
|
|
|
|
*/
|
2008-03-16 20:47:38 -04:00
|
|
|
const wxString& GetExtension() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the name of this handler.
|
|
|
|
*/
|
2008-03-16 20:47:38 -04:00
|
|
|
const wxString& GetName() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the bitmap type associated with this handler.
|
|
|
|
*/
|
2008-03-16 20:47:38 -04:00
|
|
|
wxBitmapType GetType() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-15 14:15:46 -04:00
|
|
|
Loads a bitmap from a file or resource, putting the resulting data into
|
|
|
|
@a bitmap.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bitmap
|
2008-03-09 08:33:59 -04:00
|
|
|
The bitmap object which is to be affected by this operation.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
Either a filename or a Windows resource name.
|
|
|
|
The meaning of name is determined by the type parameter.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param type
|
2008-03-16 20:47:38 -04:00
|
|
|
See ::wxBitmapType for values this can take.
|
2008-03-27 17:14:31 -04:00
|
|
|
@param desiredWidth
|
|
|
|
The desired width for the loaded bitmap.
|
|
|
|
@param desiredHeight
|
|
|
|
The desired height for the loaded bitmap.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the operation succeeded, @false otherwise.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see wxBitmap::LoadFile, wxBitmap::SaveFile, SaveFile()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
virtual bool LoadFile(wxBitmap* bitmap, const wxString& name, wxBitmapType type,
|
|
|
|
int desiredWidth, int desiredHeight);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Saves a bitmap in the named file.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bitmap
|
2008-03-09 08:33:59 -04:00
|
|
|
The bitmap object which is to be affected by this operation.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
A filename. The meaning of name is determined by the type parameter.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param type
|
2008-03-16 20:47:38 -04:00
|
|
|
See ::wxBitmapType for values this can take.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param palette
|
2008-03-09 08:33:59 -04:00
|
|
|
An optional palette used for saving the bitmap.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the operation succeeded, @false otherwise.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see wxBitmap::LoadFile, wxBitmap::SaveFile, LoadFile()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
virtual bool SaveFile(const wxBitmap* bitmap, const wxString& name, wxBitmapType type,
|
2008-03-27 17:14:31 -04:00
|
|
|
const wxPalette* palette = NULL) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the handler extension.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param extension
|
2008-03-09 08:33:59 -04:00
|
|
|
Handler extension.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetExtension(const wxString& extension);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the handler name.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
Handler name.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetName(const wxString& name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the handler type.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
|
|
|
@param type
|
2008-03-09 08:33:59 -04:00
|
|
|
Handler type.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-16 20:47:38 -04:00
|
|
|
void SetType(wxBitmapType type);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxBitmap
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class encapsulates the concept of a platform-dependent bitmap,
|
|
|
|
either monochrome or colour or colour with alpha channel support.
|
2008-09-21 16:03:14 -04:00
|
|
|
|
2008-04-10 09:21:20 -04:00
|
|
|
If you need direct access the bitmap data instead going through
|
|
|
|
drawing to it using wxMemoryDC you need to use the wxPixelData
|
|
|
|
class (either wxNativePixelData for RGB bitmaps or wxAlphaPixelData
|
|
|
|
for bitmaps with an additionaly alpha channel).
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2009-03-03 18:10:13 -05:00
|
|
|
Note that many wxBitmap functions take a @e type parameter, which is a
|
|
|
|
value of the ::wxBitmapType enumeration.
|
2008-03-15 14:15:46 -04:00
|
|
|
The validity of those values depends however on the platform where your program
|
|
|
|
is running and from the wxWidgets configuration.
|
2009-03-03 18:10:13 -05:00
|
|
|
If all possible wxWidgets settings are used:
|
|
|
|
- wxMSW supports BMP and ICO files, BMP and ICO resources;
|
|
|
|
- wxGTK supports XPM files;
|
|
|
|
- wxMac supports PICT resources;
|
|
|
|
- wxX11 supports XPM files, XPM data, XBM data;
|
|
|
|
|
|
|
|
In addition, wxBitmap can load and save all formats that wxImage can; see wxImage
|
|
|
|
for more info. Of course, you must have loaded the wxImage handlers
|
|
|
|
(see ::wxInitAllImageHandlers() and wxImage::AddHandler).
|
|
|
|
Note that all available wxBitmapHandlers for a given wxWidgets port are
|
|
|
|
automatically loaded at startup so you won't need to use wxBitmap::AddHandler.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{gdi}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@stdobjects
|
2008-03-15 14:15:46 -04:00
|
|
|
::wxNullBitmap
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-15 14:15:46 -04:00
|
|
|
@see @ref overview_bitmap, @ref overview_bitmap_supportedformats,
|
2008-04-10 09:21:20 -04:00
|
|
|
wxDC::Blit, wxIcon, wxCursor, wxMemoryDC, wxImage, wxPixelData
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxBitmap : public wxGDIObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-03-15 14:15:46 -04:00
|
|
|
Default constructor.
|
|
|
|
|
|
|
|
Constructs a bitmap object with no data; an assignment or another member
|
|
|
|
function such as Create() or LoadFile() must be called subsequently.
|
|
|
|
*/
|
|
|
|
wxBitmap();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Copy constructor, uses @ref overview_refcount "reference counting".
|
|
|
|
To make a real copy, you can use:
|
|
|
|
|
|
|
|
@code
|
|
|
|
wxBitmap newBitmap = oldBitmap.GetSubBitmap(
|
|
|
|
wxRect(0, 0, oldBitmap.GetWidth(), oldBitmap.GetHeight()));
|
|
|
|
@endcode
|
|
|
|
*/
|
|
|
|
wxBitmap(const wxBitmap& bitmap);
|
|
|
|
|
2008-03-16 20:47:38 -04:00
|
|
|
|
|
|
|
/*
|
2008-03-15 14:15:46 -04:00
|
|
|
Creates a bitmap from the given @a data which is interpreted in
|
|
|
|
platform-dependent manner.
|
|
|
|
|
|
|
|
@param data
|
|
|
|
Specifies the bitmap data in a platform-dependent format.
|
|
|
|
@param type
|
|
|
|
May be one of the ::wxBitmapType values and indicates which type of
|
|
|
|
bitmap does @a data contains. See the note in the class
|
|
|
|
detailed description.
|
|
|
|
@param width
|
|
|
|
Specifies the width of the bitmap.
|
|
|
|
@param height
|
|
|
|
Specifies the height of the bitmap.
|
|
|
|
@param depth
|
|
|
|
Specifies the depth of the bitmap.
|
|
|
|
If this is omitted, the display depth of the screen is used.
|
2008-03-16 20:47:38 -04:00
|
|
|
wxBitmap(const void* data, int type, int width, int height, int depth = -1);
|
2008-03-15 14:15:46 -04:00
|
|
|
|
|
|
|
|
2008-03-25 18:06:48 -04:00
|
|
|
NOTE: this ctor is not implemented by all ports, is somewhat useless
|
2008-03-16 20:47:38 -04:00
|
|
|
without further description of the "data" supported formats and
|
|
|
|
uses 'int type' instead of wxBitmapType, so don't document it.
|
2008-03-15 14:15:46 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
Creates a bitmap from the given array @a bits.
|
|
|
|
You should only use this function for monochrome bitmaps (depth 1) in
|
|
|
|
portable programs: in this case the bits parameter should contain an XBM image.
|
|
|
|
|
|
|
|
For other bit depths, the behaviour is platform dependent: under Windows,
|
|
|
|
the data is passed without any changes to the underlying CreateBitmap() API.
|
2008-03-16 20:47:38 -04:00
|
|
|
Under other platforms, only monochrome bitmaps may be created using this
|
|
|
|
constructor and wxImage should be used for creating colour bitmaps from
|
|
|
|
static data.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bits
|
2008-03-09 08:33:59 -04:00
|
|
|
Specifies an array of pixel values.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param width
|
2008-03-09 08:33:59 -04:00
|
|
|
Specifies the width of the bitmap.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param height
|
2008-03-09 08:33:59 -04:00
|
|
|
Specifies the height of the bitmap.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param depth
|
2008-03-15 14:15:46 -04:00
|
|
|
Specifies the depth of the bitmap.
|
2008-03-16 20:47:38 -04:00
|
|
|
If this is omitted, then a value of 1 (monochrome bitmap) is used.
|
2008-03-15 14:15:46 -04:00
|
|
|
*/
|
|
|
|
wxBitmap(const char bits[], int width, int height, int depth = 1);
|
|
|
|
|
|
|
|
/**
|
2008-03-16 20:47:38 -04:00
|
|
|
Creates a new bitmap. A depth of ::wxBITMAP_SCREEN_DEPTH indicates the
|
|
|
|
depth of the current screen or visual.
|
2008-03-25 18:06:48 -04:00
|
|
|
|
2008-03-16 20:47:38 -04:00
|
|
|
Some platforms only support 1 for monochrome and ::wxBITMAP_SCREEN_DEPTH for
|
2008-03-15 14:15:46 -04:00
|
|
|
the current colour setting.
|
|
|
|
|
|
|
|
A depth of 32 including an alpha channel is supported under MSW, Mac and GTK+.
|
|
|
|
*/
|
2008-03-16 20:47:38 -04:00
|
|
|
wxBitmap(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
|
2009-03-14 09:57:51 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
@overload
|
|
|
|
*/
|
|
|
|
wxBitmap(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH);
|
2008-03-15 14:15:46 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Creates a bitmap from XPM data.
|
|
|
|
*/
|
|
|
|
wxBitmap(const char* const* bits);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Loads a bitmap from a file or resource.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-15 14:15:46 -04:00
|
|
|
This can refer to a resource name or a filename under MS Windows and X.
|
|
|
|
Its meaning is determined by the @a type parameter.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param type
|
2008-03-15 14:15:46 -04:00
|
|
|
May be one of the ::wxBitmapType values and indicates which type of
|
|
|
|
bitmap should be loaded. See the note in the class detailed description.
|
2008-09-21 16:03:14 -04:00
|
|
|
Note that the wxBITMAP_DEFAULT_TYPE constant has different value under
|
|
|
|
different wxWidgets ports. See the bitmap.h header for the value it takes
|
|
|
|
for a specific port.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see LoadFile()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-21 16:03:14 -04:00
|
|
|
wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
|
2008-03-15 14:15:46 -04:00
|
|
|
|
|
|
|
/**
|
2008-03-16 20:47:38 -04:00
|
|
|
Creates this bitmap object from the given image.
|
|
|
|
This has to be done to actually display an image as you cannot draw an
|
|
|
|
image directly on a window.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
|
|
|
The resulting bitmap will use the provided colour depth (or that of the
|
2008-03-16 20:47:38 -04:00
|
|
|
current system if depth is ::wxBITMAP_SCREEN_DEPTH) which entails that a
|
|
|
|
colour reduction may take place.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
|
|
|
When in 8-bit mode (PseudoColour mode), the GTK port will use a color cube
|
|
|
|
created on program start-up to look up colors. This ensures a very fast conversion,
|
|
|
|
but the image quality won't be perfect (and could be better for photo images using
|
|
|
|
more sophisticated dithering algorithms).
|
|
|
|
|
|
|
|
On Windows, if there is a palette present (set with SetPalette), it will be
|
|
|
|
used when creating the wxBitmap (most useful in 8-bit display mode).
|
|
|
|
On other platforms, the palette is currently ignored.
|
|
|
|
|
|
|
|
@param img
|
|
|
|
Platform-independent wxImage object.
|
|
|
|
@param depth
|
|
|
|
Specifies the depth of the bitmap.
|
|
|
|
If this is omitted, the display depth of the screen is used.
|
|
|
|
*/
|
2008-03-16 20:47:38 -04:00
|
|
|
wxBitmap(const wxImage& img, int depth = wxBITMAP_SCREEN_DEPTH);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
2008-03-15 14:15:46 -04:00
|
|
|
See @ref overview_refcount_destruct for more info.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
If the application omits to delete the bitmap explicitly, the bitmap will be
|
|
|
|
destroyed automatically by wxWidgets when the application exits.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
|
|
|
@warning
|
2008-03-08 08:52:38 -05:00
|
|
|
Do not delete a bitmap that is selected into a memory device context.
|
|
|
|
*/
|
2008-03-24 18:17:25 -04:00
|
|
|
virtual ~wxBitmap();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Adds a handler to the end of the static list of format handlers.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param handler
|
2008-03-09 08:33:59 -04:00
|
|
|
A new bitmap format handler object. There is usually only one instance
|
|
|
|
of a given handler class in an application session.
|
2009-03-03 18:10:13 -05:00
|
|
|
|
|
|
|
Note that unlike wxImage::AddHandler, there's no documented list of
|
|
|
|
the wxBitmapHandlers available in wxWidgets.
|
|
|
|
This is because they are platform-specific and most important, they are
|
|
|
|
all automatically loaded at startup.
|
|
|
|
|
|
|
|
If you want to be sure that wxBitmap can load a certain type of image,
|
|
|
|
you'd better use wxImage::AddHandler.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see wxBitmapHandler
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static void AddHandler(wxBitmapHandler* handler);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Deletes all bitmap handlers.
|
|
|
|
This function is called by wxWidgets on exit.
|
|
|
|
*/
|
|
|
|
static void CleanUpHandlers();
|
|
|
|
|
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
virtual wxImage ConvertToImage() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Creates the bitmap from an icon.
|
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
virtual bool CopyFromIcon(const wxIcon& icon);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2008-03-15 14:15:46 -04:00
|
|
|
/**
|
|
|
|
Creates a fresh bitmap.
|
|
|
|
If the final argument is omitted, the display depth of the screen is used.
|
2009-03-14 09:57:51 -04:00
|
|
|
|
|
|
|
@return @true if the creation was successful.
|
2008-03-15 14:15:46 -04:00
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
|
2009-03-14 09:57:51 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
@overload
|
|
|
|
*/
|
|
|
|
virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH);
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-16 20:47:38 -04:00
|
|
|
/*
|
2008-03-08 08:52:38 -05:00
|
|
|
Creates a bitmap from the given data, which can be of arbitrary type.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
|
|
|
@param data
|
|
|
|
Data whose type depends on the value of type.
|
|
|
|
@param type
|
|
|
|
A bitmap type identifier; see ::wxBitmapType for the list of values.
|
|
|
|
See the note in the class detailed description for more info.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param width
|
2008-03-09 08:33:59 -04:00
|
|
|
The width of the bitmap in pixels.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param height
|
2008-03-09 08:33:59 -04:00
|
|
|
The height of the bitmap in pixels.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param depth
|
2008-03-09 08:33:59 -04:00
|
|
|
The depth of the bitmap in pixels. If this is -1, the screen depth is used.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the call succeeded, @false otherwise.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
|
|
|
This overload depends on the @a type of data.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
virtual bool Create(const void* data, int type, int width,
|
2008-03-15 14:15:46 -04:00
|
|
|
int height, int depth = -1);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2008-03-16 20:47:38 -04:00
|
|
|
NOTE: leave this undoc for the same reason of the relative ctor.
|
|
|
|
*/
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-03-15 14:15:46 -04:00
|
|
|
Finds the handler with the given @a name.
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return A pointer to the handler if found, @NULL otherwise.
|
2008-03-15 14:15:46 -04:00
|
|
|
*/
|
|
|
|
static wxBitmapHandler* FindHandler(const wxString& name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Finds the handler associated with the given @a extension and @a type.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param extension
|
2008-03-15 14:15:46 -04:00
|
|
|
The file extension, such as "bmp" (without the dot).
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bitmapType
|
2008-03-15 14:15:46 -04:00
|
|
|
The bitmap type managed by the handler, see ::wxBitmapType.
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return A pointer to the handler if found, @NULL otherwise.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
static wxBitmapHandler* FindHandler(const wxString& extension,
|
|
|
|
wxBitmapType bitmapType);
|
2008-03-15 14:15:46 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Finds the handler associated with the given bitmap type.
|
|
|
|
|
|
|
|
@param bitmapType
|
|
|
|
The bitmap type managed by the handler, see ::wxBitmapType.
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return A pointer to the handler if found, @NULL otherwise.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
|
|
|
@see wxBitmapHandler
|
|
|
|
*/
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
static wxBitmapHandler* FindHandler(wxBitmapType bitmapType);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-16 20:47:38 -04:00
|
|
|
Gets the colour depth of the bitmap.
|
|
|
|
A value of 1 indicates a monochrome bitmap.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
virtual int GetDepth() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the static list of bitmap format handlers.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see wxBitmapHandler
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2009-01-10 17:42:09 -05:00
|
|
|
static wxList& GetHandlers();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the height of the bitmap in pixels.
|
2008-11-28 17:29:29 -05:00
|
|
|
|
|
|
|
@see GetWidth(), GetSize()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
virtual int GetHeight() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the associated mask (if any) which may have been loaded from a file
|
|
|
|
or set for the bitmap.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetMask(), wxMask
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
virtual wxMask* GetMask() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the associated palette (if any) which may have been loaded from a file
|
|
|
|
or set for the bitmap.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see wxPalette
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
virtual wxPalette* GetPalette() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
virtual wxBitmap GetSubBitmap(const wxRect& rect) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2008-11-28 17:29:29 -05:00
|
|
|
/**
|
|
|
|
Returns the size of the bitmap in pixels.
|
|
|
|
|
|
|
|
@since 2.9.0
|
|
|
|
|
|
|
|
@see GetHeight(), GetWidth()
|
|
|
|
*/
|
|
|
|
wxSize GetSize() const;
|
|
|
|
|
2009-09-24 16:05:33 -04:00
|
|
|
/**
|
|
|
|
Returns disabled (dimmed) version of the bitmap.
|
|
|
|
@since 2.9.0
|
|
|
|
*/
|
|
|
|
wxBitmap ConvertToDisabled(unsigned char brightness = 255) const;
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Gets the width of the bitmap in pixels.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-11-28 17:29:29 -05:00
|
|
|
@see GetHeight(), GetSize()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
virtual int GetWidth() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Adds the standard bitmap format handlers, which, depending on wxWidgets
|
2008-03-15 14:15:46 -04:00
|
|
|
configuration, can be handlers for Windows bitmap, Windows bitmap resource,
|
|
|
|
and XPM.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This function is called by wxWidgets on startup.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see wxBitmapHandler
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static void InitStandardHandlers();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Adds a handler at the start of the static list of format handlers.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param handler
|
2008-03-09 08:33:59 -04:00
|
|
|
A new bitmap format handler object. There is usually only one instance
|
|
|
|
of a given handler class in an application session.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see wxBitmapHandler
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static void InsertHandler(wxBitmapHandler* handler);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if bitmap data is present.
|
|
|
|
*/
|
2008-10-13 07:09:56 -04:00
|
|
|
virtual bool IsOk() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Loads a bitmap from a file or resource.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
Either a filename or a Windows resource name.
|
2008-03-15 14:15:46 -04:00
|
|
|
The meaning of name is determined by the @a type parameter.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param type
|
2008-03-15 14:15:46 -04:00
|
|
|
One of the ::wxBitmapType values; see the note in the class
|
|
|
|
detailed description.
|
2008-09-21 16:03:14 -04:00
|
|
|
Note that the wxBITMAP_DEFAULT_TYPE constant has different value under
|
|
|
|
different wxWidgets ports. See the bitmap.h header for the value it takes
|
|
|
|
for a specific port.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the operation succeeded, @false otherwise.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@remarks A palette may be associated with the bitmap if one exists
|
2008-03-09 08:33:59 -04:00
|
|
|
(especially for colour Windows bitmaps), and if the
|
|
|
|
code supports it. You can check if one has been created
|
2008-03-15 14:15:46 -04:00
|
|
|
by using the GetPalette() member.
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SaveFile()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-21 16:03:14 -04:00
|
|
|
virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-15 14:15:46 -04:00
|
|
|
Finds the handler with the given name, and removes it.
|
|
|
|
The handler is not deleted.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
The handler name.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the handler was found and removed, @false otherwise.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see wxBitmapHandler
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static bool RemoveHandler(const wxString& name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Saves a bitmap in the named file.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
A filename. The meaning of name is determined by the type parameter.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param type
|
2008-03-15 14:15:46 -04:00
|
|
|
One of the ::wxBitmapType values; see the note in the class
|
|
|
|
detailed description.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param palette
|
2008-03-09 08:33:59 -04:00
|
|
|
An optional palette used for saving the bitmap.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the operation succeeded, @false otherwise.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@remarks Depending on how wxWidgets has been configured, not all formats
|
2008-03-09 08:33:59 -04:00
|
|
|
may be available.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see LoadFile()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
virtual bool SaveFile(const wxString& name, wxBitmapType type,
|
|
|
|
const wxPalette* palette = NULL) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the depth member (does not affect the bitmap data).
|
2008-03-15 14:15:46 -04:00
|
|
|
|
|
|
|
@todo since these functions do not affect the bitmap data,
|
|
|
|
why they exist??
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param depth
|
2008-03-09 08:33:59 -04:00
|
|
|
Bitmap depth.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
virtual void SetDepth(int depth);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the height member (does not affect the bitmap data).
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param height
|
2008-03-09 08:33:59 -04:00
|
|
|
Bitmap height in pixels.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
virtual void SetHeight(int height);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the mask for this bitmap.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@remarks The bitmap object owns the mask once this has been called.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetMask(), wxMask
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
virtual void SetMask(wxMask* mask);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the associated palette. (Not implemented under GTK+).
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param palette
|
2008-03-09 08:33:59 -04:00
|
|
|
The palette to set.
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see wxPalette
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
virtual void SetPalette(const wxPalette& palette);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the width member (does not affect the bitmap data).
|
2008-03-15 14:15:46 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param width
|
2008-03-09 08:33:59 -04:00
|
|
|
Bitmap width in pixels.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
virtual void SetWidth(int width);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
/**
|
2008-03-15 14:15:46 -04:00
|
|
|
An empty wxBitmap object.
|
2008-03-10 11:24:38 -04:00
|
|
|
*/
|
|
|
|
wxBitmap wxNullBitmap;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxMask
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class encapsulates a monochrome mask bitmap, where the masked area is
|
2008-03-15 14:15:46 -04:00
|
|
|
black and the unmasked area is white.
|
|
|
|
|
|
|
|
When associated with a bitmap and drawn in a device context, the unmasked
|
|
|
|
area of the bitmap will be drawn, and the masked area will not be drawn.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{gdi}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxBitmap, wxDC::Blit, wxMemoryDC
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxMask : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
2008-03-15 14:15:46 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Default constructor.
|
|
|
|
*/
|
|
|
|
wxMask();
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Constructs a mask from a bitmap and a palette index that indicates the
|
2008-03-15 14:15:46 -04:00
|
|
|
background.
|
|
|
|
Not yet implemented for GTK.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bitmap
|
2008-03-09 08:33:59 -04:00
|
|
|
A valid bitmap.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param index
|
2008-03-09 08:33:59 -04:00
|
|
|
Index into a palette, specifying the transparency colour.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxMask(const wxBitmap& bitmap, int index);
|
2008-03-15 14:15:46 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Constructs a mask from a monochrome bitmap.
|
|
|
|
|
|
|
|
@beginWxPythonOnly
|
|
|
|
This is the default constructor for wxMask in wxPython.
|
|
|
|
@endWxPythonOnly
|
|
|
|
*/
|
|
|
|
wxMask(const wxBitmap& bitmap);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Constructs a mask from a bitmap and a colour that indicates the background.
|
|
|
|
|
|
|
|
@beginWxPythonOnly
|
|
|
|
wxPython has an alternate wxMask constructor matching this form called wxMaskColour.
|
|
|
|
@endWxPythonOnly
|
|
|
|
*/
|
|
|
|
wxMask(const wxBitmap& bitmap, const wxColour& colour);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destroys the wxMask object and the underlying bitmap data.
|
|
|
|
*/
|
2008-03-24 18:17:25 -04:00
|
|
|
virtual ~wxMask();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Constructs a mask from a bitmap and a palette index that indicates the
|
2008-03-15 14:15:46 -04:00
|
|
|
background.
|
|
|
|
Not yet implemented for GTK.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bitmap
|
2008-03-09 08:33:59 -04:00
|
|
|
A valid bitmap.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param index
|
2008-03-09 08:33:59 -04:00
|
|
|
Index into a palette, specifying the transparency colour.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-15 14:15:46 -04:00
|
|
|
bool Create(const wxBitmap& bitmap, int index);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Constructs a mask from a monochrome bitmap.
|
|
|
|
*/
|
2008-03-08 08:52:38 -05:00
|
|
|
bool Create(const wxBitmap& bitmap);
|
2008-03-15 14:15:46 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Constructs a mask from a bitmap and a colour that indicates the background.
|
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
bool Create(const wxBitmap& bitmap, const wxColour& colour);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|