This is the base class for implementing image file loading/saving, and image creation from data.
It is used within Image and is not normally seen by the application.
If you wish to extend the capabilities of Image, derive a class from ImageHandler and add the handler using Image.AddHandler in your application initialization.
Note that all ImageHandlers provided by wxWidgets are part of the Core library. For details about the default handlers, please see the section Available image handlers in the Image class documentation.
This software is based in part on the work of the Independent JPEG Group. (Applies when wxWidgets is linked with JPEG support. JPEGHandler uses libjpeg created by IJG.)
See also
__init__ | Default constructor. |
CanRead | Returns True if this handler supports the image format contained in the given stream. |
DoCanRead | Called to test if this handler can read an image from the given stream. |
DoGetImageCount | Called to get the number of images available in a multi-image file type, if supported. |
GetAltExtensions | Returns the other file extensions associated with this handler. |
GetExtension | Gets the preferred file extension associated with this handler. |
GetImageCount | 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. |
GetMimeType | Gets the MIME type associated with this handler. |
GetName | Gets the name of this handler. |
GetType | Gets the image type associated with this handler. |
LoadFile | Loads a image from a stream, putting the resulting data into image. |
SaveFile | Saves a image in the output stream. |
SetAltExtensions | Sets the alternative file extensions associated with this handler. |
SetExtension | Sets the preferred file extension associated with this handler. |
SetMimeType | Sets the handler MIME type. |
SetName | Sets the handler name. |
AltExtensions | See GetAltExtensions and SetAltExtensions |
Extension | See GetExtension and SetExtension |
MimeType | See GetMimeType and SetMimeType |
Name | See GetName and SetName |
Type | See GetType |
This is the base class for implementing image file loading/saving, and image creation from data.
Possible constructors:
ImageHandler()
Default constructor.
In your own default constructor, initialise the members m_name, m_extension and m_type.
Overloaded Implementations:
CanRead (self, 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 StreamBase.IsSeekable ).
Parameters: | stream (InputStream) – |
---|---|
Return type: | bool |
CanRead (self, 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 StreamBase.IsSeekable ).
Parameters: | filename (string) – |
---|---|
Return type: | bool |
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
Parameters: | stream (InputStream) – |
---|---|
Return type: | bool |
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
Parameters: | stream (InputStream) – |
---|---|
Return type: | int |
Returns the other file extensions associated with this handler.
The preferred extension for this handler is returned by GetExtension .
Return type: | list of strings |
---|
New in version 2.9.0.
Gets the preferred file extension associated with this handler.
Return type: | string |
---|
See also
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.
Parameters: | stream (InputStream) – 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 StreamBase.IsSeekable ). |
---|---|
Return type: | int |
Returns: | Number of available images. For most image handlers, this is 1 (exceptions are TIFF and ICO formats as well as animated GIFs for which this function returns the number of frames in the animation). |
Gets the MIME type associated with this handler.
Return type: | string |
---|
Gets the name of this handler.
Return type: | string |
---|
Gets the image type associated with this handler.
Return type: | BitmapType |
---|
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.
Parameters: |
|
---|---|
Return type: | bool |
Returns: | True if the operation succeeded, False otherwise. |
See also
Saves a image in the output stream.
Parameters: |
|
---|---|
Return type: | bool |
Returns: | True if the operation succeeded, False otherwise. |
See also
Sets the alternative file extensions associated with this handler.
Parameters: | extensions (list of strings) – Array of file extensions. |
---|
New in version 2.9.0.
See also
Sets the preferred file extension associated with this handler.
Parameters: | extension (string) – File extension without leading dot. |
---|
See also
Sets the handler MIME type.
Parameters: | mimetype (string) – Handler MIME type. |
---|
Sets the handler name.
Parameters: | name (string) – Handler name. |
---|
See GetAltExtensions and SetAltExtensions
See GetExtension and SetExtension
See GetMimeType and SetMimeType