- Main Page
- Namespaces
- Classes
- Files
- Examples

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Exiv2::ImageFactory Class Reference

Returns an Image instance of the specified type. More...

`#include <image.hpp>`

List of all members.

## Static Public Member Functions
Manipulators
static void | registerImage (int type, NewInstanceFct newInst, IsThisTypeFct isType)
| Register image type together with its function pointers.
Accessors
static Image::AutoPtr | open (const std::string &path)
| Create an Image subclass of the appropriate type by reading the specified file. Image type is derived from the file contents.
static Image::AutoPtr | open (const byte *data, long size)
| Create an Image subclass of the appropriate type by reading the provided memory. Image type is derived from the memory contents.
static Image::AutoPtr | open (BasicIo::AutoPtr io)
| Create an Image subclass of the appropriate type by reading the provided BasicIo instance. Image type is derived from the data provided by io. The passed in io instance is (re)opened by this method.
static Image::AutoPtr | create (int type, const std::string &path)
| Create an Image subclass of the requested type by creating a new image file. If the file already exists, it will be overwritten.
static Image::AutoPtr | create (int type)
| Create an Image subclass of the requested type by creating a new image in memory.
static Image::AutoPtr | create (int type, BasicIo::AutoPtr io)
| Create an Image subclass of the requested type by writing a new image to a BasicIo instance. If the BasicIo instance already contains data, it will be overwritten.
static int | getType (const std::string &path)
| Returns the image type of the provided file.
static int | getType (const byte *data, long size)
| Returns the image type of the provided data buffer.
static int | getType (BasicIo &io)
| Returns the image type of data provided by a BasicIo instance. The passed in io instance is (re)opened by this method.
## Classes
struct | Registry
| Struct for storing image types and function pointers.

## Detailed Description

Returns an Image instance of the specified type.

The factory is implemented as a static class.

## Member Function Documentation

Image::AutoPtr Exiv2::ImageFactory::create | ( | int | type,
|  | BasicIo::AutoPtr | io
| ) | `[static]`

  | Create an Image subclass of the requested type by writing a new image to a BasicIo instance. If the BasicIo instance already contains data, it will be overwritten. Parameters:
  | type | Type of the image to be created.
  | io | An auto-pointer that owns a BasicIo instance that will be written to when creating a new image.
Note: This method takes ownership of the passed in BasicIo instance through the auto-pointer. Callers should not continue to use the BasicIo instance after it is passed to this method. Use the Image::io() method to get a temporary reference. Returns: An auto-pointer that owns an Image instance of the requested type. If the image type is not supported, the pointer is 0.

Image::AutoPtr Exiv2::ImageFactory::create | ( | int | type | ) | `[static]`

  | Create an Image subclass of the requested type by creating a new image in memory. Parameters:
  | type | Type of the image to be created.
  Returns: An auto-pointer that owns an Image instance of the requested type. Exceptions:
  | Error | If the image type is not supported

Image::AutoPtr Exiv2::ImageFactory::create | ( | int | type,
|  | const std::string & | path
| ) | `[static]`

  | Create an Image subclass of the requested type by creating a new image file. If the file already exists, it will be overwritten. Parameters:
  | type | Type of the image to be created.
  | path | Image file to create. File extension is ignored.
  Returns: An auto-pointer that owns an Image instance of the requested type. Exceptions:
  | Error | If the image type is not supported.

int Exiv2::ImageFactory::getType | ( | BasicIo & | io | ) | `[static]`

  | Returns the image type of data provided by a BasicIo instance. The passed in io instance is (re)opened by this method. Parameters:
  | io | A BasicIo instance that provides image data. The contents of the image data are tested to determine the type.
Returns: Image type or Image::none if the type is not recognized.

int Exiv2::ImageFactory::getType | ( | const byte * | data,
|  | long | size
| ) | `[static]`

  | Returns the image type of the provided data buffer. Parameters:
  | data | Pointer to a data buffer containing an image. The contents of the memory are tested to determine the image type.
  | size | Number of bytes pointed to by data.
Returns: Image type or Image::none if the type is not recognized.

int Exiv2::ImageFactory::getType | ( | const std::string & | path | ) | `[static]`

  | Returns the image type of the provided file. Parameters:
  | path | Image file. The contents of the file are tested to determine the image type. File extension is ignored.
Returns: Image type or Image::none if the type is not recognized.

Image::AutoPtr Exiv2::ImageFactory::open | ( | BasicIo::AutoPtr | io | ) | `[static]`

  | Create an Image subclass of the appropriate type by reading the provided BasicIo instance. Image type is derived from the data provided by io. The passed in io instance is (re)opened by this method. Parameters:
  | io | An auto-pointer that owns a BasicIo instance that provides image data. The contents of the image data are tested to determine the type.
  Note: This method takes ownership of the passed in BasicIo instance through the auto-pointer. Callers should not continue to use the BasicIo instance after it is passed to this method. Use the Image::io() method to get a temporary reference. Returns: An auto-pointer that owns an Image instance whose type matches that of the io data. If no image type could be determined, the pointer is 0. Exceptions:
  | Error | If opening the BasicIo fails

Image::AutoPtr Exiv2::ImageFactory::open | ( | const byte * | data,
|  | long | size
| ) | `[static]`

  | Create an Image subclass of the appropriate type by reading the provided memory. Image type is derived from the memory contents. Parameters:
  | data | Pointer to a data buffer containing an image. The contents of the memory are tested to determine the image type.
  | size | Number of bytes pointed to by data.
  Returns: An auto-pointer that owns an Image instance whose type matches that of the data buffer. Exceptions:
  | Error | If the memory contains data of an unknown image type.

Image::AutoPtr Exiv2::ImageFactory::open | ( | const std::string & | path | ) | `[static]`

  | Create an Image subclass of the appropriate type by reading the specified file. Image type is derived from the file contents. Parameters:
  | path | Image file. The contents of the file are tested to determine the image type. File extension is ignored.
  Returns: An auto-pointer that owns an Image instance whose type matches that of the file. Exceptions:
  | Error | If opening the file fails or it contains data of an unknown image type.
Examples: addmoddel.cpp, exifcomment.cpp, exifprint.cpp, iptceasy.cpp, and iptcprint.cpp.

void Exiv2::ImageFactory::registerImage | ( | int | type,
|  | NewInstanceFct | newInst,
|  | IsThisTypeFct | isType
| ) | `[static]`

  | Register image type together with its function pointers. The image factory creates new images by calling their associated function pointer. Additional images can be added by registering new type and function pointers. If called for a type that already exists in the list, the corresponding functions are replaced. Parameters:
  | type | Image type.
  | newInst | Function pointer for creating image instances.
  | isType | Function pointer to test for matching image types.

The documentation for this class was generated from the following files:

- image.hpp
- image.cpp
- imgreg.cpp