#include <wx/image.h>
This is the base class for implementing image file loading/saving, and image creation from data.
It is used within wxImage and is not normally seen by the application.
If you wish to extend the capabilities of wxImage, derive a class from wxImageHandler and add the handler using wxImage::AddHandler in your application initialization.
Note that all wxImageHandlers provided by wxWidgets are part of the wxCore library. For details about the default handlers, please see the section Available image handlers in the wxImage class documentation.
This software is based in part on the work of the Independent JPEG Group. (Applies when wxWidgets is linked with JPEG support. wxJPEGHandler uses libjpeg created by IJG.)
Predefined objects/pointers: wxNullImage
Public Member Functions | |
wxImageHandler () | |
Default constructor. | |
virtual | ~wxImageHandler () |
Destroys the wxImageHandler object. | |
bool | CanRead (wxInputStream &stream) |
Returns true if this handler supports the image format contained in the given stream. | |
bool | CanRead (const wxString &filename) |
Returns true if this handler supports the image format contained in the file with the given name. | |
const wxString & | GetExtension () const |
Gets the preferred file extension associated with this handler. | |
const wxArrayString & | GetAltExtensions () const |
Returns the other file extensions associated with this handler. | |
virtual int | GetImageCount (wxInputStream &stream) |
If the image file contains more than one image and the image handler is capable of retrieving these individually, this function will return the number of available images. | |
const wxString & | GetMimeType () const |
Gets the MIME type associated with this handler. | |
const wxString & | GetName () const |
Gets the name of this handler. | |
wxBitmapType | GetType () const |
Gets the image type associated with this handler. | |
virtual bool | LoadFile (wxImage *image, wxInputStream &stream, bool verbose=true, int index=-1) |
Loads a image from a stream, putting the resulting data into image. | |
virtual bool | SaveFile (wxImage *image, wxOutputStream &stream, bool verbose=true) |
Saves a image in the output stream. | |
void | SetExtension (const wxString &extension) |
Sets the preferred file extension associated with this handler. | |
void | SetAltExtensions (const wxArrayString &extensions) |
Sets the alternative file extensions associated with this handler. | |
void | SetMimeType (const wxString &mimetype) |
Sets the handler MIME type. | |
void | SetName (const wxString &name) |
Sets the handler name. | |
Public Member Functions inherited from wxObject | |
wxObject () | |
Default ctor; initializes to NULL the internal reference data. | |
wxObject (const wxObject &other) | |
Copy ctor. | |
virtual | ~wxObject () |
Destructor. | |
virtual wxClassInfo * | GetClassInfo () const |
This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar). | |
wxObjectRefData * | GetRefData () const |
Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. | |
bool | IsKindOf (const wxClassInfo *info) const |
Determines whether this class is a subclass of (or the same class as) the given class. | |
bool | IsSameAs (const wxObject &obj) const |
Returns true if this object has the same data pointer as obj. | |
void | Ref (const wxObject &clone) |
Makes this object refer to the data in clone. | |
void | SetRefData (wxObjectRefData *data) |
Sets the wxObject::m_refData pointer. | |
void | UnRef () |
Decrements the reference count in the associated data, and if it is zero, deletes the data. | |
void | UnShare () |
This is the same of AllocExclusive() but this method is public. | |
void | operator delete (void *buf) |
The delete operator is defined for debugging versions of the library only, when the identifier WXDEBUG is defined. | |
void * | operator new (size_t size, const wxString &filename=NULL, int lineNum=0) |
The new operator is defined for debugging versions of the library only, when the identifier WXDEBUG is defined. | |
Static Public Member Functions | |
static wxVersionInfo | GetLibraryVersionInfo () |
Retrieve the version information about the image library used by this handler. | |
Protected Member Functions | |
virtual int | DoGetImageCount (wxInputStream &stream) |
Called to get the number of images available in a multi-image file type, if supported. | |
virtual bool | DoCanRead (wxInputStream &stream)=0 |
Called to test if this handler can read an image from the given stream. | |
Protected Member Functions inherited from wxObject | |
void | AllocExclusive () |
Ensure that this object's data is not shared with any other object. | |
virtual wxObjectRefData * | CreateRefData () const |
Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. | |
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const |
Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data. | |
Additional Inherited Members | |
Protected Attributes inherited from wxObject | |
wxObjectRefData * | m_refData |
Pointer to an object which is the object's reference-counted data. | |
wxImageHandler::wxImageHandler | ( | ) |
Default constructor.
In your own default constructor, initialise the members m_name, m_extension and m_type.
|
virtual |
Destroys the wxImageHandler object.
bool wxImageHandler::CanRead | ( | wxInputStream & | stream | ) |
Returns true if this handler supports the image format contained in the given stream.
This function doesn't modify the current stream position (because it restores the original position before returning; this however requires the stream to be seekable; see wxStreamBase::IsSeekable).
bool wxImageHandler::CanRead | ( | const wxString & | filename | ) |
Returns true if this handler supports the image format contained in the file with the given name.
This function doesn't modify the current stream position (because it restores the original position before returning; this however requires the stream to be seekable; see wxStreamBase::IsSeekable).
|
protectedpure virtual |
Called to test if this handler can read an image from the given stream.
NOTE: this function is allowed to change the current stream position since CallDoCanRead() will take care of restoring it later
|
protectedvirtual |
Called to get the number of images available in a multi-image file type, if supported.
NOTE: this function is allowed to change the current stream position since GetImageCount() will take care of restoring it later
const wxArrayString& wxImageHandler::GetAltExtensions | ( | ) | const |
Returns the other file extensions associated with this handler.
The preferred extension for this handler is returned by GetExtension().
const wxString& wxImageHandler::GetExtension | ( | ) | const |
Gets the preferred file extension associated with this handler.
|
virtual |
If the image file contains more than one image and the image handler is capable of retrieving these individually, this function will return the number of available images.
stream | Opened input stream for reading image data. This function doesn't modify the current stream position (because it restores the original position before returning; this however requires the stream to be seekable; see wxStreamBase::IsSeekable). |
|
static |
Retrieve the version information about the image library used by this handler.
This method is not present in wxImageHandler class itself but is present in a few of the classes deriving from it, currently wxJPEGHandler, wxPNGHandler and wxTIFFHandler. It returns the information about the version of the image library being used for the corresponding handler implementation.
const wxString& wxImageHandler::GetMimeType | ( | ) | const |
Gets the MIME type associated with this handler.
const wxString& wxImageHandler::GetName | ( | ) | const |
Gets the name of this handler.
wxBitmapType wxImageHandler::GetType | ( | ) | const |
Gets the image type associated with this handler.
|
virtual |
Loads a image from a stream, putting the resulting data into image.
If the image file contains more than one image and the image handler is capable of retrieving these individually, index indicates which image to read from the stream.
image | The image object which is to be affected by this operation. |
stream | Opened input stream for reading image data. |
verbose | If set to true, errors reported by the image handler will produce wxLogMessages. |
index | The index of the image in the file (starting from zero). |
|
virtual |
Saves a image in the output stream.
image | The image object which is to be affected by this operation. |
stream | Opened output stream for writing the data. |
verbose | If set to true, errors reported by the image handler will produce wxLogMessages. |
void wxImageHandler::SetAltExtensions | ( | const wxArrayString & | extensions | ) |
Sets the alternative file extensions associated with this handler.
extensions | Array of file extensions. |
void wxImageHandler::SetExtension | ( | const wxString & | extension | ) |
Sets the preferred file extension associated with this handler.
extension | File extension without leading dot. |
void wxImageHandler::SetMimeType | ( | const wxString & | mimetype | ) |
Sets the handler MIME type.
mimetype | Handler MIME type. |
void wxImageHandler::SetName | ( | const wxString & | name | ) |
Sets the handler name.
name | Handler name. |