## wxImageHandler

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

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

Derived from

wxObject

Include files

<wx/image.h>

See also

wxImage, wxInitAllImageHandlers

Members

wxImageHandler::wxImageHandler
wxImageHandler::~wxImageHandler
wxImageHandler::GetName
wxImageHandler::GetExtension
wxImageHandler::GetImageCount
wxImageHandler::GetType
wxImageHandler::GetMimeType
wxImageHandler::LoadFile
wxImageHandler::SaveFile
wxImageHandler::SetName
wxImageHandler::SetExtension
wxImageHandler::SetMimeType
wxImageHandler::SetType

### wxImageHandler::wxImageHandler

wxImageHandler()

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

### wxImageHandler::~wxImageHandler

~wxImageHandler()

Destroys the wxImageHandler object.

### wxImageHandler::GetName

wxString GetName() const

Gets the name of this handler.

### wxImageHandler::GetExtension

wxString GetExtension() const

Gets the file extension associated with this handler.

### wxImageHandler::GetImageCount

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.

stream

Opened input stream for reading image data. Currently, the stream must support seeking.

Return value

Number of available images. For most image handlers, this is 1 (exceptions are TIFF and ICO formats).

### wxImageHandler::GetType

long GetType() const

Gets the image type associated with this handler.

### wxImageHandler::GetMimeType

wxString GetMimeType() const

Gets the MIME type associated with this handler.

### wxImageHandler::LoadFile

bool LoadFile(wxImage* image, wxInputStream& stream, bool verbose=true, int index=0)

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

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

Return value

true if the operation succeeded, false otherwise.

See also

wxImage::LoadFile, wxImage::SaveFile, wxImageHandler::SaveFile

### wxImageHandler::SaveFile

bool SaveFile(wxImage* image, wxOutputStream& stream)

Saves a image in the output stream.

Parameters

image

The image object which is to be affected by this operation.

stream

Opened output stream for writing the data.

Return value

true if the operation succeeded, false otherwise.

See also

wxImage::LoadFile, wxImage::SaveFile, wxImageHandler::LoadFile

### wxImageHandler::SetName

void SetName(const wxString& name)

Sets the handler name.

Parameters

name

Handler name.

### wxImageHandler::SetExtension

void SetExtension(const wxString& extension)

Sets the handler extension.

Parameters

extension

Handler extension.

### wxImageHandler::SetMimeType

void SetMimeType(const wxString& mimetype)

Sets the handler MIME type.

Parameters

mimename

Handler MIME type.

### wxImageHandler::SetType

void SetType(long type)

Sets the handler type.

Parameters

name

Handler type.