Version: 2.9.4
Public Member Functions | Static Public Member Functions | Protected Member Functions
wxImageHandler Class Reference

#include </home/zeitlin/src/wx/github/interface/wx/image.h>

Inheritance diagram for wxImageHandler:

Detailed Description

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.

Note (Legal Issue)

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

Library:  wxCore
Category:  Graphics Device Interface (GDI)
参照:
wxImage, wxInitAllImageHandlers()

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 wxStringGetExtension () const
 Gets the preferred file extension associated with this handler.
const wxArrayStringGetAltExtensions () 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 wxStringGetMimeType () const
 Gets the MIME type associated with this handler.
const wxStringGetName () 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.

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.

List of all members.


Constructor & Destructor Documentation

wxImageHandler::wxImageHandler ( )

Default constructor.

In your own default constructor, initialise the members m_name, m_extension and m_type.

virtual wxImageHandler::~wxImageHandler ( ) [virtual]

Destroys the wxImageHandler object.


Member Function Documentation

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).

virtual bool wxImageHandler::DoCanRead ( wxInputStream stream) [protected, pure 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

virtual int wxImageHandler::DoGetImageCount ( wxInputStream stream) [protected, virtual]

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().

Since:
2.9.0
const wxString& wxImageHandler::GetExtension ( ) const

Gets the preferred file extension associated with this handler.

参照:
GetAltExtensions()
virtual int wxImageHandler::GetImageCount ( wxInputStream stream) [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.

Parameters:
streamOpened 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).
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).
static wxVersionInfo wxImageHandler::GetLibraryVersionInfo ( ) [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.

Since:
2.9.2
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 bool wxImageHandler::LoadFile ( wxImage image,
wxInputStream stream,
bool  verbose = true,
int  index = -1 
) [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.

Parameters:
imageThe image object which is to be affected by this operation.
streamOpened input stream for reading image data.
verboseIf set to true, errors reported by the image handler will produce wxLogMessages.
indexThe index of the image in the file (starting from zero).
Returns:
true if the operation succeeded, false otherwise.
参照:
wxImage::LoadFile, wxImage::SaveFile, SaveFile()
virtual bool wxImageHandler::SaveFile ( wxImage image,
wxOutputStream stream,
bool  verbose = true 
) [virtual]

Saves a image in the output stream.

Parameters:
imageThe image object which is to be affected by this operation.
streamOpened output stream for writing the data.
verboseIf set to true, errors reported by the image handler will produce wxLogMessages.
Returns:
true if the operation succeeded, false otherwise.
参照:
wxImage::LoadFile, wxImage::SaveFile, LoadFile()
void wxImageHandler::SetAltExtensions ( const wxArrayString extensions)

Sets the alternative file extensions associated with this handler.

Parameters:
extensionsArray of file extensions.
参照:
SetExtension()
Since:
2.9.0
void wxImageHandler::SetExtension ( const wxString extension)

Sets the preferred file extension associated with this handler.

Parameters:
extensionFile extension without leading dot.
参照:
SetAltExtensions()
void wxImageHandler::SetMimeType ( const wxString mimetype)

Sets the handler MIME type.

Parameters:
mimetypeHandler MIME type.
void wxImageHandler::SetName ( const wxString name)

Sets the handler name.

Parameters:
nameHandler name.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines