X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c83d207b76c07ce2008622545ee61f9df5fb3803..72c5855f5c9e6b5747dc9571d64e217eff26561d:/interface/wx/bitmap.h diff --git a/interface/wx/bitmap.h b/interface/wx/bitmap.h index ce3e67080d..5b6e278644 100644 --- a/interface/wx/bitmap.h +++ b/interface/wx/bitmap.h @@ -3,7 +3,7 @@ // Purpose: interface of wxBitmap* classes // Author: wxWidgets team // RCS-ID: $Id$ -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -165,7 +165,7 @@ public: 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). + for bitmaps with an additionally alpha channel). Note that many wxBitmap functions take a @e type parameter, which is a value of the ::wxBitmapType enumeration. @@ -183,6 +183,17 @@ public: Note that all available wxBitmapHandlers for a given wxWidgets port are automatically loaded at startup so you won't need to use wxBitmap::AddHandler. + More on the difference between wxImage and wxBitmap: wxImage is just a + buffer of RGB bytes with an optional buffer for the alpha bytes. It is all + generic, platform independent and image file format independent code. It + includes generic code for scaling, resizing, clipping, and other manipulations + of the image data. OTOH, wxBitmap is intended to be a wrapper of whatever is + the native image format that is quickest/easiest to draw to a DC or to be the + target of the drawing operations performed on a wxMemoryDC. By splitting the + responsibilities between wxImage/wxBitmap like this then it's easier to use + generic code shared by all platforms and image types for generic operations and + platform specific code where performance or compatibility is needed. + @library{wxcore} @category{gdi} @@ -260,6 +271,10 @@ public: @param depth Specifies the depth of the bitmap. If this is omitted, then a value of 1 (monochrome bitmap) is used. + + @beginWxPerlOnly + In wxPerl use Wx::Bitmap->newFromBits(bits, width, height, depth). + @endWxPerlOnly */ wxBitmap(const char bits[], int width, int height, int depth = 1); @@ -273,9 +288,18 @@ public: A depth of 32 including an alpha channel is supported under MSW, Mac and GTK+. */ wxBitmap(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH); + + /** + @overload + */ + wxBitmap(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH); /** Creates a bitmap from XPM data. + + @beginWxPerlOnly + In wxPerl use Wx::Bitmap->newFromXPM(data). + @endWxPerlOnly */ wxBitmap(const char* const* bits); @@ -374,10 +398,15 @@ public: /** Creates a fresh bitmap. If the final argument is omitted, the display depth of the screen is used. - - This overload works on all platforms. + + @return @true if the creation was successful. */ virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH); + + /** + @overload + */ + virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH); /* Creates a bitmap from the given data, which can be of arbitrary type. @@ -488,6 +517,15 @@ public: */ wxSize GetSize() const; + /** + Returns disabled (dimmed) version of the bitmap. + + This method is not available when wxUSE_IMAGE == 0. + + @since 2.9.0 + */ + wxBitmap ConvertToDisabled(unsigned char brightness = 255) const; + /** Gets the width of the bitmap in pixels. @@ -546,6 +584,31 @@ public: */ virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE); + /** + Loads a bitmap from the memory containing image data in PNG format. + + This helper function provides the simplest way to create a wxBitmap + from PNG image data. On most platforms, it's simply a wrapper around + wxImage loading functions and so requires the PNG image handler to be + registered by either calling wxInitAllImageHandlers() which also + registers all the other image formats or including the necessary + header: + @code + #include + @endcode + and calling + @code + wxImage::AddHandler(new wxPNGHandler); + @endcode + in your application startup code. + + However under OS X this function uses native image loading and so + doesn't require wxWidgets PNG support. + + @since 2.9.5 + */ + static wxBitmap NewFromPNGData(const void* data, size_t size); + /** Finds the handler with the given name, and removes it. The handler is not deleted. @@ -672,19 +735,11 @@ public: /** 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); @@ -714,5 +769,13 @@ public: Constructs a mask from a bitmap and a colour that indicates the background. */ bool Create(const wxBitmap& bitmap, const wxColour& colour); + + /** + Returns the mask as a monochrome bitmap. + Currently this method is implemented in wxMSW, wxGTK and wxOSX. + + @since 2.9.5 + */ + wxBitmap GetBitmap() const; };