Base-class for codecs that can read and write image file formats such as PNG, JPEG, etc. More...
#include <juce_ImageFileFormat.h>
Public Member Functions | |
virtual | ~ImageFileFormat ()=default |
Destructor. More... | |
virtual bool | canUnderstand (InputStream &input)=0 |
Returns true if the given stream seems to contain data that this format understands. More... | |
virtual Image | decodeImage (InputStream &input)=0 |
Tries to decode and return an image from the given stream. More... | |
virtual String | getFormatName ()=0 |
Returns a description of this file format. More... | |
virtual bool | usesFileExtension (const File &possibleFile)=0 |
Returns true if this format uses the file extension of the given file. More... | |
virtual bool | writeImageToStream (const Image &sourceImage, OutputStream &destStream)=0 |
Attempts to write an image to a stream. More... | |
Static Public Member Functions | |
static ImageFileFormat * | findImageFormatForFileExtension (const File &file) |
Looks for a format that can handle the given file extension. More... | |
static ImageFileFormat * | findImageFormatForStream (InputStream &input) |
Tries the built-in formats to see if it can find one to read this stream. More... | |
static Image | loadFrom (const File &file) |
Tries to load an image from a file. More... | |
static Image | loadFrom (const void *rawData, size_t numBytesOfData) |
Tries to load an image from a block of raw image data. More... | |
static Image | loadFrom (InputStream &input) |
Tries to load an image from a stream. More... | |
Protected Member Functions | |
ImageFileFormat ()=default | |
Creates an ImageFormat. More... | |
Base-class for codecs that can read and write image file formats such as PNG, JPEG, etc.
This class also contains static methods to make it easy to load images from files, streams or from memory.
@tags{Graphics}
|
protecteddefault |
Creates an ImageFormat.
|
virtualdefault |
Destructor.
|
pure virtual |
Returns true if the given stream seems to contain data that this format understands.
The format class should only read the first few bytes of the stream and sniff for header bytes that it understands.
Note that this will advance the stream and leave it in a new position, so if you're planning on re-using it, you may want to rewind it after calling this method.
Implemented in juce::GIFImageFormat, juce::JPEGImageFormat, and juce::PNGImageFormat.
|
pure virtual |
Tries to decode and return an image from the given stream.
This will be called for an image format after calling its canUnderStand() method to see if it can handle the stream.
input | the stream to read the data from. The stream will be positioned at the start of the image data (but this may not necessarily be position 0) |
Implemented in juce::GIFImageFormat, juce::JPEGImageFormat, and juce::PNGImageFormat.
|
static |
Looks for a format that can handle the given file extension.
There are currently built-in formats for PNG, JPEG and GIF formats. The object that is returned should not be deleted by the caller.
|
static |
Tries the built-in formats to see if it can find one to read this stream.
There are currently built-in decoders for PNG, JPEG and GIF formats. The object that is returned should not be deleted by the caller.
|
pure virtual |
Returns a description of this file format.
E.g. "JPEG", "PNG"
Implemented in juce::GIFImageFormat, juce::JPEGImageFormat, and juce::PNGImageFormat.
Tries to load an image from a file.
This will use the findImageFormatForStream() method to locate a suitable codec, and use that to load the image.
|
static |
Tries to load an image from a block of raw image data.
This will use the findImageFormatForStream() method to locate a suitable codec, and use that to load the image.
|
static |
Tries to load an image from a stream.
This will use the findImageFormatForStream() method to locate a suitable codec, and use that to load the image.
Returns true if this format uses the file extension of the given file.
Implemented in juce::GIFImageFormat, juce::JPEGImageFormat, and juce::PNGImageFormat.
|
pure virtual |
Attempts to write an image to a stream.
To specify extra information like encoding quality, there will be appropriate parameters in the subclasses of the specific file types.
Implemented in juce::GIFImageFormat, juce::JPEGImageFormat, and juce::PNGImageFormat.