|
Packit Service |
21b5d1 |
// ***************************************************************** -*- C++ -*-
|
|
Packit Service |
21b5d1 |
/*
|
|
Packit Service |
21b5d1 |
* Copyright (C) 2004-2018 Exiv2 authors
|
|
Packit Service |
21b5d1 |
* This program is part of the Exiv2 distribution.
|
|
Packit Service |
21b5d1 |
*
|
|
Packit Service |
21b5d1 |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
21b5d1 |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
21b5d1 |
* as published by the Free Software Foundation; either version 2
|
|
Packit Service |
21b5d1 |
* of the License, or (at your option) any later version.
|
|
Packit Service |
21b5d1 |
*
|
|
Packit Service |
21b5d1 |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
21b5d1 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
21b5d1 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
21b5d1 |
* GNU General Public License for more details.
|
|
Packit Service |
21b5d1 |
*
|
|
Packit Service |
21b5d1 |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
21b5d1 |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
21b5d1 |
* Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@file image.hpp
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
#ifndef IMAGE_HPP_
|
|
Packit Service |
21b5d1 |
#define IMAGE_HPP_
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
// *****************************************************************************
|
|
Packit Service |
21b5d1 |
#include "exiv2lib_export.h"
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
// included header files
|
|
Packit Service |
21b5d1 |
#include "basicio.hpp"
|
|
Packit Service |
21b5d1 |
#include "exif.hpp"
|
|
Packit Service |
21b5d1 |
#include "iptc.hpp"
|
|
Packit Service |
21b5d1 |
#include "xmp_exiv2.hpp"
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
// + standard includes
|
|
Packit Service |
21b5d1 |
#include <string>
|
|
Packit Service |
21b5d1 |
#include <vector>
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
// *****************************************************************************
|
|
Packit Service |
21b5d1 |
// namespace extensions
|
|
Packit Service |
21b5d1 |
namespace Exiv2 {
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
// *****************************************************************************
|
|
Packit Service |
21b5d1 |
// class definitions
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
//! Supported image formats
|
|
Packit Service |
21b5d1 |
namespace ImageType {
|
|
Packit Service |
21b5d1 |
const int none = 0; //!< Not an image
|
|
Packit Service |
21b5d1 |
}
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
//! Native preview information. This is meant to be used only by the PreviewManager.
|
|
Packit Service |
21b5d1 |
struct NativePreview {
|
|
Packit Service |
21b5d1 |
long position_; //!< Position
|
|
Packit Service |
21b5d1 |
uint32_t size_; //!< Size
|
|
Packit Service |
21b5d1 |
uint32_t width_; //!< Width
|
|
Packit Service |
21b5d1 |
uint32_t height_; //!< Height
|
|
Packit Service |
21b5d1 |
std::string filter_; //!< Filter
|
|
Packit Service |
21b5d1 |
std::string mimeType_; //!< MIME type
|
|
Packit Service |
21b5d1 |
};
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
//! List of native previews. This is meant to be used only by the PreviewManager.
|
|
Packit Service |
21b5d1 |
typedef std::vector<NativePreview> NativePreviewList;
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Options for printStructure
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
typedef enum { kpsNone, kpsBasic, kpsXMP, kpsRecursive
|
|
Packit Service |
21b5d1 |
, kpsIccProfile , kpsIptcErase
|
|
Packit Service |
21b5d1 |
} PrintStructureOption;
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Abstract base class defining the interface for an image. This is
|
|
Packit Service |
21b5d1 |
the top-level interface to the Exiv2 library.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
Image has containers to store image metadata and subclasses implement
|
|
Packit Service |
21b5d1 |
read and save metadata from and to specific image formats.
|
|
Packit Service |
21b5d1 |
Most client apps will obtain an Image instance by calling a static
|
|
Packit Service |
21b5d1 |
ImageFactory method. The Image class can then be used to to read, write,
|
|
Packit Service |
21b5d1 |
and save metadata.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
class EXIV2API Image {
|
|
Packit Service |
21b5d1 |
public:
|
|
Packit Service |
21b5d1 |
//! Image auto_ptr type
|
|
Packit Service |
21b5d1 |
typedef std::auto_ptr<Image> AutoPtr;
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
//! @name Creators
|
|
Packit Service |
21b5d1 |
//@{
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Constructor taking the image type, a bitmap of the supported
|
|
Packit Service |
21b5d1 |
metadata types and an auto-pointer that owns an IO instance.
|
|
Packit Service |
21b5d1 |
See subclass constructor doc.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
Image(int imageType,
|
|
Packit Service |
21b5d1 |
uint16_t supportedMetadata,
|
|
Packit Service |
21b5d1 |
BasicIo::AutoPtr io);
|
|
Packit Service |
21b5d1 |
//! Virtual Destructor
|
|
Packit Service |
21b5d1 |
virtual ~Image();
|
|
Packit Service |
21b5d1 |
//@}
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
//! @name Manipulators
|
|
Packit Service |
21b5d1 |
//@{
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Print out the structure of image file.
|
|
Packit Service |
21b5d1 |
@throw Error if reading of the file fails or the image data is
|
|
Packit Service |
21b5d1 |
not valid (does not look like data of the specific image type).
|
|
Packit Service |
21b5d1 |
@warning This function is not thread safe and intended for exiv2 -pS for debugging.
|
|
Packit Service |
21b5d1 |
@warning You may need to put the stream into binary mode (see src/actions.cpp)
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual void printStructure(std::ostream& out, PrintStructureOption option =kpsNone, int depth=0);
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Read all metadata supported by a specific image format from the
|
|
Packit Service |
21b5d1 |
image. Before this method is called, the image metadata will be
|
|
Packit Service |
21b5d1 |
cleared.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
This method returns success even if no metadata is found in the
|
|
Packit Service |
21b5d1 |
image. Callers must therefore check the size of individual metadata
|
|
Packit Service |
21b5d1 |
types before accessing the data.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
@throw Error if opening or reading of the file fails or the image
|
|
Packit Service |
21b5d1 |
data is not valid (does not look like data of the specific image
|
|
Packit Service |
21b5d1 |
type).
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual void readMetadata() =0;
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Write metadata back to the image.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
All existing metadata sections in the image are either created,
|
|
Packit Service |
21b5d1 |
replaced, or erased. If values for a given metadata type have been
|
|
Packit Service |
21b5d1 |
assigned, a section for that metadata type will either be created or
|
|
Packit Service |
21b5d1 |
replaced. If no values have been assigned to a given metadata type,
|
|
Packit Service |
21b5d1 |
any exists section for that metadata type will be removed from the
|
|
Packit Service |
21b5d1 |
image.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
@throw Error if the operation fails
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual void writeMetadata() =0;
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Assign new Exif data. The new Exif data is not written
|
|
Packit Service |
21b5d1 |
to the image until the writeMetadata() method is called.
|
|
Packit Service |
21b5d1 |
@param exifData An ExifData instance holding Exif data to be copied
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual void setExifData(const ExifData& exifData);
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Erase any buffered Exif data. Exif data is not removed from
|
|
Packit Service |
21b5d1 |
the actual image until the writeMetadata() method is called.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual void clearExifData();
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Assign new IPTC data. The new IPTC data is not written
|
|
Packit Service |
21b5d1 |
to the image until the writeMetadata() method is called.
|
|
Packit Service |
21b5d1 |
@param iptcData An IptcData instance holding IPTC data to be copied
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual void setIptcData(const IptcData& iptcData);
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Erase any buffered IPTC data. IPTC data is not removed from
|
|
Packit Service |
21b5d1 |
the actual image until the writeMetadata() method is called.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual void clearIptcData();
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Assign a raw XMP packet. The new XMP packet is not written
|
|
Packit Service |
21b5d1 |
to the image until the writeMetadata() method is called.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
Subsequent calls to writeMetadata() write the XMP packet from
|
|
Packit Service |
21b5d1 |
the buffered raw XMP packet rather than from buffered parsed XMP
|
|
Packit Service |
21b5d1 |
data. In order to write from parsed XMP data again, use
|
|
Packit Service |
21b5d1 |
either writeXmpFromPacket(false) or setXmpData().
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
@param xmpPacket A string containing the raw XMP packet.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual void setXmpPacket(const std::string& xmpPacket);
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Erase the buffered XMP packet. XMP data is not removed from
|
|
Packit Service |
21b5d1 |
the actual image until the writeMetadata() method is called.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
This has the same effect as clearXmpData() but operates on the
|
|
Packit Service |
21b5d1 |
buffered raw XMP packet only, not the parsed XMP data.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
Subsequent calls to writeMetadata() write the XMP packet from
|
|
Packit Service |
21b5d1 |
the buffered raw XMP packet rather than from buffered parsed XMP
|
|
Packit Service |
21b5d1 |
data. In order to write from parsed XMP data again, use
|
|
Packit Service |
21b5d1 |
either writeXmpFromPacket(false) or setXmpData().
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual void clearXmpPacket();
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Assign new XMP data. The new XMP data is not written
|
|
Packit Service |
21b5d1 |
to the image until the writeMetadata() method is called.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
Subsequent calls to writeMetadata() encode the XMP data to
|
|
Packit Service |
21b5d1 |
a raw XMP packet and write the newly encoded packet to the image.
|
|
Packit Service |
21b5d1 |
In the process, the buffered raw XMP packet is updated.
|
|
Packit Service |
21b5d1 |
In order to write directly from the raw XMP packet, use
|
|
Packit Service |
21b5d1 |
writeXmpFromPacket(true) or setXmpPacket().
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
@param xmpData An XmpData instance holding XMP data to be copied
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual void setXmpData(const XmpData& xmpData);
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Erase any buffered XMP data. XMP data is not removed from
|
|
Packit Service |
21b5d1 |
the actual image until the writeMetadata() method is called.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
This has the same effect as clearXmpPacket() but operates on the
|
|
Packit Service |
21b5d1 |
buffered parsed XMP data.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
Subsequent calls to writeMetadata() encode the XMP data to
|
|
Packit Service |
21b5d1 |
a raw XMP packet and write the newly encoded packet to the image.
|
|
Packit Service |
21b5d1 |
In the process, the buffered raw XMP packet is updated.
|
|
Packit Service |
21b5d1 |
In order to write directly from the raw XMP packet, use
|
|
Packit Service |
21b5d1 |
writeXmpFromPacket(true) or setXmpPacket().
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual void clearXmpData();
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Set the image comment. The new comment is not written
|
|
Packit Service |
21b5d1 |
to the image until the writeMetadata() method is called.
|
|
Packit Service |
21b5d1 |
@param comment String containing comment.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual void setComment(const std::string& comment);
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Erase any buffered comment. Comment is not removed
|
|
Packit Service |
21b5d1 |
from the actual image until the writeMetadata() method is called.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual void clearComment();
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Set the image iccProfile. The new profile is not written
|
|
Packit Service |
21b5d1 |
to the image until the writeMetadata() method is called.
|
|
Packit Service |
21b5d1 |
@param iccProfile DataBuf containing profile (binary)
|
|
Packit Service |
21b5d1 |
@param bTestValid - tests that iccProfile contains credible data
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual void setIccProfile(DataBuf& iccProfile,bool bTestValid=true);
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Erase iccProfile. the profile is not removed from
|
|
Packit Service |
21b5d1 |
the actual image until the writeMetadata() method is called.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual void clearIccProfile();
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Erase iccProfile. the profile is not removed from
|
|
Packit Service |
21b5d1 |
the actual image until the writeMetadata() method is called.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual bool iccProfileDefined() { return iccProfile_.size_?true:false;}
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief return iccProfile
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual DataBuf* iccProfile() { return &iccProfile_; }
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Copy all existing metadata from source Image. The data is
|
|
Packit Service |
21b5d1 |
copied into internal buffers and is not written to the image
|
|
Packit Service |
21b5d1 |
until the writeMetadata() method is called.
|
|
Packit Service |
21b5d1 |
@param image Metadata source. All metadata types are copied.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual void setMetadata(const Image& image);
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Erase all buffered metadata. Metadata is not removed
|
|
Packit Service |
21b5d1 |
from the actual image until the writeMetadata() method is called.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual void clearMetadata();
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Returns an ExifData instance containing currently buffered
|
|
Packit Service |
21b5d1 |
Exif data.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
The contained Exif data may have been read from the image by
|
|
Packit Service |
21b5d1 |
a previous call to readMetadata() or added directly. The Exif
|
|
Packit Service |
21b5d1 |
data in the returned instance will be written to the image when
|
|
Packit Service |
21b5d1 |
writeMetadata() is called.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
@return modifiable ExifData instance containing Exif values
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual ExifData& exifData();
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Returns an IptcData instance containing currently buffered
|
|
Packit Service |
21b5d1 |
IPTC data.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
The contained IPTC data may have been read from the image by
|
|
Packit Service |
21b5d1 |
a previous call to readMetadata() or added directly. The IPTC
|
|
Packit Service |
21b5d1 |
data in the returned instance will be written to the image when
|
|
Packit Service |
21b5d1 |
writeMetadata() is called.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
@return modifiable IptcData instance containing IPTC values
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual IptcData& iptcData();
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Returns an XmpData instance containing currently buffered
|
|
Packit Service |
21b5d1 |
XMP data.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
The contained XMP data may have been read from the image by
|
|
Packit Service |
21b5d1 |
a previous call to readMetadata() or added directly. The XMP
|
|
Packit Service |
21b5d1 |
data in the returned instance will be written to the image when
|
|
Packit Service |
21b5d1 |
writeMetadata() is called.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
@return modifiable XmpData instance containing XMP values
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual XmpData& xmpData();
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Return a modifiable reference to the raw XMP packet.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual std::string& xmpPacket();
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Determine the source when writing XMP.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
Depending on the setting of this flag, writeMetadata() writes
|
|
Packit Service |
21b5d1 |
XMP from the buffered raw XMP packet or from parsed XMP data.
|
|
Packit Service |
21b5d1 |
The default is to write from parsed XMP data. The switch is also
|
|
Packit Service |
21b5d1 |
set by all functions to set and clear the buffered raw XMP packet
|
|
Packit Service |
21b5d1 |
and parsed XMP data, so using this function should usually not be
|
|
Packit Service |
21b5d1 |
necessary.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
If %Exiv2 was compiled without XMP support, the default for this
|
|
Packit Service |
21b5d1 |
flag is true and it will never be changed in order to preserve
|
|
Packit Service |
21b5d1 |
access to the raw XMP packet.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
void writeXmpFromPacket(bool flag);
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Set the byte order to encode the Exif metadata in.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
The setting is only used when new Exif metadata is created and may
|
|
Packit Service |
21b5d1 |
not be applicable at all for some image formats. If the target image
|
|
Packit Service |
21b5d1 |
already contains Exif metadata, the byte order of the existing data
|
|
Packit Service |
21b5d1 |
is used. If byte order is not set when writeMetadata() is called,
|
|
Packit Service |
21b5d1 |
little-endian byte order (II) is used by default.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
void setByteOrder(ByteOrder byteOrder);
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Print out the structure of image file.
|
|
Packit Service |
21b5d1 |
@throw Error if reading of the file fails or the image data is
|
|
Packit Service |
21b5d1 |
not valid (does not look like data of the specific image type).
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
void printTiffStructure(BasicIo& io,std::ostream& out, PrintStructureOption option,int depth,size_t offset=0);
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Print out the structure of a TIFF IFD
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
void printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStructureOption option,uint32_t start,bool bSwap,char c,int depth);
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief is the host platform bigEndian
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
bool isBigEndianPlatform();
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief is the host platform littleEndian
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
bool isLittleEndianPlatform();
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
bool isStringType(uint16_t type);
|
|
Packit Service |
21b5d1 |
bool isShortType(uint16_t type);
|
|
Packit Service |
21b5d1 |
bool isLongType(uint16_t type);
|
|
Packit Service |
21b5d1 |
bool isLongLongType(uint16_t type);
|
|
Packit Service |
21b5d1 |
bool isRationalType(uint16_t type);
|
|
Packit Service |
21b5d1 |
bool is2ByteType(uint16_t type);
|
|
Packit Service |
21b5d1 |
bool is4ByteType(uint16_t type);
|
|
Packit Service |
21b5d1 |
bool is8ByteType(uint16_t type);
|
|
Packit Service |
21b5d1 |
bool isPrintXMP(uint16_t type, Exiv2::PrintStructureOption option);
|
|
Packit Service |
21b5d1 |
bool isPrintICC(uint16_t type, Exiv2::PrintStructureOption option);
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
uint64_t byteSwap(uint64_t value,bool bSwap) const;
|
|
Packit Service |
21b5d1 |
uint32_t byteSwap(uint32_t value,bool bSwap) const;
|
|
Packit Service |
21b5d1 |
uint16_t byteSwap(uint16_t value,bool bSwap) const;
|
|
Packit Service |
21b5d1 |
uint16_t byteSwap2(const DataBuf& buf,size_t offset,bool bSwap) const;
|
|
Packit Service |
21b5d1 |
uint32_t byteSwap4(const DataBuf& buf,size_t offset,bool bSwap) const;
|
|
Packit Service |
21b5d1 |
uint64_t byteSwap8(const DataBuf& buf,size_t offset,bool bSwap) const;
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
//@}
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
//! @name Accessors
|
|
Packit Service |
21b5d1 |
//@{
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Return the byte order in which the Exif metadata of the image is
|
|
Packit Service |
21b5d1 |
encoded. Initially, it is not set (\em invalidByteOrder).
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
ByteOrder byteOrder() const;
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Check if the Image instance is valid. Use after object
|
|
Packit Service |
21b5d1 |
construction.
|
|
Packit Service |
21b5d1 |
@return true if the Image is in a valid state.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
bool good() const;
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Return the MIME type of the image.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
@note For each supported image format, the library knows only one MIME
|
|
Packit Service |
21b5d1 |
type. This may not be the most specific MIME type for that format. In
|
|
Packit Service |
21b5d1 |
particular, several RAW formats are variants of the TIFF format with
|
|
Packit Service |
21b5d1 |
the same magic as TIFF itself. Class TiffImage handles most of them
|
|
Packit Service |
21b5d1 |
and thus they all have MIME type "image/tiff", although a more
|
|
Packit Service |
21b5d1 |
specific MIME type may exist (e.g., "image/x-nikon-nef").
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual std::string mimeType() const =0;
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Return the pixel width of the image.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual int pixelWidth() const;
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Return the pixel height of the image.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual int pixelHeight() const;
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Returns an ExifData instance containing currently buffered
|
|
Packit Service |
21b5d1 |
Exif data.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
The Exif data may have been read from the image by
|
|
Packit Service |
21b5d1 |
a previous call to readMetadata() or added directly. The Exif
|
|
Packit Service |
21b5d1 |
data in the returned instance will be written to the image when
|
|
Packit Service |
21b5d1 |
writeMetadata() is called.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
@return read only ExifData instance containing Exif values
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual const ExifData& exifData() const;
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Returns an IptcData instance containing currently buffered
|
|
Packit Service |
21b5d1 |
IPTC data.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
The contained IPTC data may have been read from the image by
|
|
Packit Service |
21b5d1 |
a previous call to readMetadata() or added directly. The IPTC
|
|
Packit Service |
21b5d1 |
data in the returned instance will be written to the image when
|
|
Packit Service |
21b5d1 |
writeMetadata() is called.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
@return modifiable IptcData instance containing IPTC values
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual const IptcData& iptcData() const;
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Returns an XmpData instance containing currently buffered
|
|
Packit Service |
21b5d1 |
XMP data.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
The contained XMP data may have been read from the image by
|
|
Packit Service |
21b5d1 |
a previous call to readMetadata() or added directly. The XMP
|
|
Packit Service |
21b5d1 |
data in the returned instance will be written to the image when
|
|
Packit Service |
21b5d1 |
writeMetadata() is called.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
@return modifiable XmpData instance containing XMP values
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual const XmpData& xmpData() const;
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Return a copy of the image comment. May be an empty string.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual std::string comment() const;
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Return the raw XMP packet as a string.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual const std::string& xmpPacket() const;
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Return a reference to the BasicIo instance being used for Io.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
This refence is particularly useful to reading the results of
|
|
Packit Service |
21b5d1 |
operations on a MemIo instance. For example after metadata has
|
|
Packit Service |
21b5d1 |
been modified and the writeMetadata() method has been called,
|
|
Packit Service |
21b5d1 |
this method can be used to get access to the modified image.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
@return BasicIo instance that can be used to read or write image
|
|
Packit Service |
21b5d1 |
data directly.
|
|
Packit Service |
21b5d1 |
@note If the returned BasicIo is used to write to the image, the
|
|
Packit Service |
21b5d1 |
Image class will not see those changes until the readMetadata()
|
|
Packit Service |
21b5d1 |
method is called.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
virtual BasicIo& io() const;
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Returns the access mode, i.e., the metadata functions, which
|
|
Packit Service |
21b5d1 |
this image supports for the metadata type \em metadataId.
|
|
Packit Service |
21b5d1 |
@param metadataId The metadata identifier.
|
|
Packit Service |
21b5d1 |
@return Access mode for the requested image type and metadata identifier.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
AccessMode checkMode(MetadataId metadataId) const;
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Check if image supports a particular type of metadata.
|
|
Packit Service |
21b5d1 |
This method is deprecated. Use checkMode() instead.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
bool supportsMetadata(MetadataId metadataId) const;
|
|
Packit Service |
21b5d1 |
//! Return the flag indicating the source when writing XMP metadata.
|
|
Packit Service |
21b5d1 |
bool writeXmpFromPacket() const;
|
|
Packit Service |
21b5d1 |
//! Return list of native previews. This is meant to be used only by the PreviewManager.
|
|
Packit Service |
21b5d1 |
const NativePreviewList& nativePreviews() const;
|
|
Packit Service |
21b5d1 |
//@}
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
//! set type support for this image format
|
|
Packit Service |
21b5d1 |
void setTypeSupported(
|
|
Packit Service |
21b5d1 |
int imageType,
|
|
Packit Service |
21b5d1 |
uint16_t supportedMetadata
|
|
Packit Service |
21b5d1 |
) {
|
|
Packit Service |
21b5d1 |
imageType_ = imageType;
|
|
Packit Service |
21b5d1 |
supportedMetadata_ = supportedMetadata;
|
|
Packit Service |
21b5d1 |
}
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
//! set type support for this image format
|
|
Packit Service |
21b5d1 |
int imageType() const { return imageType_; }
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
protected:
|
|
Packit Service |
21b5d1 |
// DATA
|
|
Packit Service |
21b5d1 |
BasicIo::AutoPtr io_; //!< Image data IO pointer
|
|
Packit Service |
21b5d1 |
ExifData exifData_; //!< Exif data container
|
|
Packit Service |
21b5d1 |
IptcData iptcData_; //!< IPTC data container
|
|
Packit Service |
21b5d1 |
XmpData xmpData_; //!< XMP data container
|
|
Packit Service |
21b5d1 |
DataBuf iccProfile_; //!< ICC buffer (binary data)
|
|
Packit Service |
21b5d1 |
std::string comment_; //!< User comment
|
|
Packit Service |
21b5d1 |
std::string xmpPacket_; //!< XMP packet
|
|
Packit Service |
21b5d1 |
int pixelWidth_; //!< image pixel width
|
|
Packit Service |
21b5d1 |
int pixelHeight_; //!< image pixel height
|
|
Packit Service |
21b5d1 |
NativePreviewList nativePreviews_; //!< list of native previews
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
//! Return tag name for given tag id.
|
|
Packit Service |
21b5d1 |
const std::string& tagName(uint16_t tag);
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
//! Return tag type for given tag id.
|
|
Packit Service |
21b5d1 |
const char* typeName(uint16_t tag) const;
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
private:
|
|
Packit Service |
21b5d1 |
//! @name NOT implemented
|
|
Packit Service |
21b5d1 |
//@{
|
|
Packit Service |
21b5d1 |
//! Copy constructor
|
|
Packit Service |
21b5d1 |
Image(const Image& rhs);
|
|
Packit Service |
21b5d1 |
//! Assignment operator
|
|
Packit Service |
21b5d1 |
Image& operator=(const Image& rhs);
|
|
Packit Service |
21b5d1 |
//@}
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
// DATA
|
|
Packit Service |
21b5d1 |
int imageType_; //!< Image type
|
|
Packit Service |
21b5d1 |
uint16_t supportedMetadata_; //!< Bitmap with all supported metadata types
|
|
Packit Service |
21b5d1 |
bool writeXmpFromPacket_;//!< Determines the source when writing XMP
|
|
Packit Service |
21b5d1 |
ByteOrder byteOrder_; //!< Byte order
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
std::map<int,std::string> tags_; //!< Map of tags
|
|
Packit Service |
21b5d1 |
bool init_; //!< Flag marking if map of tags needs to be initialized
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
}; // class Image
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
//! Type for function pointer that creates new Image instances
|
|
Packit Service |
21b5d1 |
typedef Image::AutoPtr (*NewInstanceFct)(BasicIo::AutoPtr io, bool create);
|
|
Packit Service |
21b5d1 |
//! Type for function pointer that checks image types
|
|
Packit Service |
21b5d1 |
typedef bool (*IsThisTypeFct)(BasicIo& iIo, bool advance);
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Returns an Image instance of the specified type.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
The factory is implemented as a static class.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
class EXIV2API ImageFactory {
|
|
Packit Service |
21b5d1 |
friend bool Image::good() const;
|
|
Packit Service |
21b5d1 |
public:
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Create the appropriate class type implemented BasicIo based on the protocol of the input.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
"-" path implies the data from stdin and it is handled by StdinIo.
|
|
Packit Service |
21b5d1 |
Http path can be handled by either HttpIo or CurlIo. Https, ftp paths
|
|
Packit Service |
21b5d1 |
are handled by CurlIo. Ssh, sftp paths are handled by SshIo. Others are handled by FileIo.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
@param path %Image file.
|
|
Packit Service |
21b5d1 |
@param useCurl Indicate whether the libcurl is used or not.
|
|
Packit Service |
21b5d1 |
If it's true, http is handled by CurlIo. Otherwise it is handled by HttpIo.
|
|
Packit Service |
21b5d1 |
@return An auto-pointer that owns an BasicIo instance.
|
|
Packit Service |
21b5d1 |
@throw Error If the file is not found or it is unable to connect to the server to
|
|
Packit Service |
21b5d1 |
read the remote file.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
static BasicIo::AutoPtr createIo(const std::string& path, bool useCurl = true);
|
|
Packit Service |
21b5d1 |
#ifdef EXV_UNICODE_PATH
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Like createIo() but accepts a unicode path in an std::wstring.
|
|
Packit Service |
21b5d1 |
@note This function is only available on Windows.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
static BasicIo::AutoPtr createIo(const std::wstring& wpath, bool useCurl = true);
|
|
Packit Service |
21b5d1 |
#endif
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Create an Image subclass of the appropriate type by reading
|
|
Packit Service |
21b5d1 |
the specified file. %Image type is derived from the file
|
|
Packit Service |
21b5d1 |
contents.
|
|
Packit Service |
21b5d1 |
@param path %Image file. The contents of the file are tested to
|
|
Packit Service |
21b5d1 |
determine the image type. File extension is ignored.
|
|
Packit Service |
21b5d1 |
@param useCurl Indicate whether the libcurl is used or not.
|
|
Packit Service |
21b5d1 |
If it's true, http is handled by CurlIo. Otherwise it is handled by HttpIo.
|
|
Packit Service |
21b5d1 |
@return An auto-pointer that owns an Image instance whose type
|
|
Packit Service |
21b5d1 |
matches that of the file.
|
|
Packit Service |
21b5d1 |
@throw Error If opening the file fails or it contains data of an
|
|
Packit Service |
21b5d1 |
unknown image type.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
static Image::AutoPtr open(const std::string& path, bool useCurl = true);
|
|
Packit Service |
21b5d1 |
#ifdef EXV_UNICODE_PATH
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Like open() but accepts a unicode path in an std::wstring.
|
|
Packit Service |
21b5d1 |
@note This function is only available on Windows.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
static Image::AutoPtr open(const std::wstring& wpath, bool useCurl = true);
|
|
Packit Service |
21b5d1 |
#endif
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Create an Image subclass of the appropriate type by reading
|
|
Packit Service |
21b5d1 |
the provided memory. %Image type is derived from the memory
|
|
Packit Service |
21b5d1 |
contents.
|
|
Packit Service |
21b5d1 |
@param data Pointer to a data buffer containing an image. The contents
|
|
Packit Service |
21b5d1 |
of the memory are tested to determine the image type.
|
|
Packit Service |
21b5d1 |
@param size Number of bytes pointed to by \em data.
|
|
Packit Service |
21b5d1 |
@return An auto-pointer that owns an Image instance whose type
|
|
Packit Service |
21b5d1 |
matches that of the data buffer.
|
|
Packit Service |
21b5d1 |
@throw Error If the memory contains data of an unknown image type.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
static Image::AutoPtr open(const byte* data, long size);
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Create an Image subclass of the appropriate type by reading
|
|
Packit Service |
21b5d1 |
the provided BasicIo instance. %Image type is derived from the
|
|
Packit Service |
21b5d1 |
data provided by \em io. The passed in \em io instance is
|
|
Packit Service |
21b5d1 |
(re)opened by this method.
|
|
Packit Service |
21b5d1 |
@param io An auto-pointer that owns a BasicIo instance that provides
|
|
Packit Service |
21b5d1 |
image data. The contents of the image data are tested to determine
|
|
Packit Service |
21b5d1 |
the type.
|
|
Packit Service |
21b5d1 |
@note This method takes ownership of the passed
|
|
Packit Service |
21b5d1 |
in BasicIo instance through the auto-pointer. Callers should not
|
|
Packit Service |
21b5d1 |
continue to use the BasicIo instance after it is passed to this method.
|
|
Packit Service |
21b5d1 |
Use the Image::io() method to get a temporary reference.
|
|
Packit Service |
21b5d1 |
@return An auto-pointer that owns an Image instance whose type
|
|
Packit Service |
21b5d1 |
matches that of the \em io data. If no image type could be
|
|
Packit Service |
21b5d1 |
determined, the pointer is 0.
|
|
Packit Service |
21b5d1 |
@throw Error If opening the BasicIo fails
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
static Image::AutoPtr open(BasicIo::AutoPtr io);
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Create an Image subclass of the requested type by creating a
|
|
Packit Service |
21b5d1 |
new image file. If the file already exists, it will be overwritten.
|
|
Packit Service |
21b5d1 |
@param type Type of the image to be created.
|
|
Packit Service |
21b5d1 |
@param path %Image file to create. File extension is ignored.
|
|
Packit Service |
21b5d1 |
@return An auto-pointer that owns an Image instance of the requested
|
|
Packit Service |
21b5d1 |
type.
|
|
Packit Service |
21b5d1 |
@throw Error If the image type is not supported.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
static Image::AutoPtr create(int type, const std::string& path);
|
|
Packit Service |
21b5d1 |
#ifdef EXV_UNICODE_PATH
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Like create() but accepts a unicode path in an std::wstring.
|
|
Packit Service |
21b5d1 |
@note This function is only available on Windows.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
static Image::AutoPtr create(int type, const std::wstring& wpath);
|
|
Packit Service |
21b5d1 |
#endif
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Create an Image subclass of the requested type by creating a
|
|
Packit Service |
21b5d1 |
new image in memory.
|
|
Packit Service |
21b5d1 |
@param type Type of the image to be created.
|
|
Packit Service |
21b5d1 |
@return An auto-pointer that owns an Image instance of the requested
|
|
Packit Service |
21b5d1 |
type.
|
|
Packit Service |
21b5d1 |
@throw Error If the image type is not supported
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
static Image::AutoPtr create(int type);
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Create an Image subclass of the requested type by writing a
|
|
Packit Service |
21b5d1 |
new image to a BasicIo instance. If the BasicIo instance already
|
|
Packit Service |
21b5d1 |
contains data, it will be overwritten.
|
|
Packit Service |
21b5d1 |
@param type Type of the image to be created.
|
|
Packit Service |
21b5d1 |
@param io An auto-pointer that owns a BasicIo instance that will
|
|
Packit Service |
21b5d1 |
be written to when creating a new image.
|
|
Packit Service |
21b5d1 |
@note This method takes ownership of the passed in BasicIo instance
|
|
Packit Service |
21b5d1 |
through the auto-pointer. Callers should not continue to use the
|
|
Packit Service |
21b5d1 |
BasicIo instance after it is passed to this method. Use the
|
|
Packit Service |
21b5d1 |
Image::io() method to get a temporary reference.
|
|
Packit Service |
21b5d1 |
@return An auto-pointer that owns an Image instance of the requested
|
|
Packit Service |
21b5d1 |
type. If the image type is not supported, the pointer is 0.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
static Image::AutoPtr create(int type, BasicIo::AutoPtr io);
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Returns the image type of the provided file.
|
|
Packit Service |
21b5d1 |
@param path %Image file. The contents of the file are tested to
|
|
Packit Service |
21b5d1 |
determine the image type. File extension is ignored.
|
|
Packit Service |
21b5d1 |
@return %Image type or Image::none if the type is not recognized.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
static int getType(const std::string& path);
|
|
Packit Service |
21b5d1 |
#ifdef EXV_UNICODE_PATH
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Like getType() but accepts a unicode path in an std::wstring.
|
|
Packit Service |
21b5d1 |
@note This function is only available on Windows.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
static int getType(const std::wstring& wpath);
|
|
Packit Service |
21b5d1 |
#endif
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Returns the image type of the provided data buffer.
|
|
Packit Service |
21b5d1 |
@param data Pointer to a data buffer containing an image. The contents
|
|
Packit Service |
21b5d1 |
of the memory are tested to determine the image type.
|
|
Packit Service |
21b5d1 |
@param size Number of bytes pointed to by \em data.
|
|
Packit Service |
21b5d1 |
@return %Image type or Image::none if the type is not recognized.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
static int getType(const byte* data, long size);
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Returns the image type of data provided by a BasicIo instance.
|
|
Packit Service |
21b5d1 |
The passed in \em io instance is (re)opened by this method.
|
|
Packit Service |
21b5d1 |
@param io A BasicIo instance that provides image data. The contents
|
|
Packit Service |
21b5d1 |
of the image data are tested to determine the type.
|
|
Packit Service |
21b5d1 |
@return %Image type or Image::none if the type is not recognized.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
static int getType(BasicIo& io);
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Returns the access mode or supported metadata functions for an
|
|
Packit Service |
21b5d1 |
image type and a metadata type.
|
|
Packit Service |
21b5d1 |
@param type The image type.
|
|
Packit Service |
21b5d1 |
@param metadataId The metadata identifier.
|
|
Packit Service |
21b5d1 |
@return Access mode for the requested image type and metadata identifier.
|
|
Packit Service |
21b5d1 |
@throw Error(kerUnsupportedImageType) if the image type is not supported.
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
static AccessMode checkMode(int type, MetadataId metadataId);
|
|
Packit Service |
21b5d1 |
/*!
|
|
Packit Service |
21b5d1 |
@brief Determine if the content of \em io is an image of \em type.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
The \em advance flag determines if the read position in the
|
|
Packit Service |
21b5d1 |
stream is moved (see below). This applies only if the type
|
|
Packit Service |
21b5d1 |
matches and the function returns true. If the type does not
|
|
Packit Service |
21b5d1 |
match, the stream position is not changed. However, if
|
|
Packit Service |
21b5d1 |
reading from the stream fails, the stream position is
|
|
Packit Service |
21b5d1 |
undefined. Consult the stream state to obtain more
|
|
Packit Service |
21b5d1 |
information in this case.
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
@param type Type of the image.
|
|
Packit Service |
21b5d1 |
@param io BasicIo instance to read from.
|
|
Packit Service |
21b5d1 |
@param advance Flag indicating whether the position of the io
|
|
Packit Service |
21b5d1 |
should be advanced by the number of characters read to
|
|
Packit Service |
21b5d1 |
analyse the data (true) or left at its original
|
|
Packit Service |
21b5d1 |
position (false). This applies only if the type matches.
|
|
Packit Service |
21b5d1 |
@return true if the data matches the type of this class;
|
|
Packit Service |
21b5d1 |
false if the data does not match
|
|
Packit Service |
21b5d1 |
*/
|
|
Packit Service |
21b5d1 |
static bool checkType(int type, BasicIo& io, bool advance);
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
private:
|
|
Packit Service |
21b5d1 |
//! @name Creators
|
|
Packit Service |
21b5d1 |
//@{
|
|
Packit Service |
21b5d1 |
//! Prevent construction: not implemented.
|
|
Packit Service |
21b5d1 |
ImageFactory();
|
|
Packit Service |
21b5d1 |
//! Prevent copy construction: not implemented.
|
|
Packit Service |
21b5d1 |
ImageFactory(const ImageFactory& rhs);
|
|
Packit Service |
21b5d1 |
//@}
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
}; // class ImageFactory
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
// *****************************************************************************
|
|
Packit Service |
21b5d1 |
// template, inline and free functions
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
//! Append \em len bytes pointed to by \em buf to \em blob.
|
|
Packit Service |
21b5d1 |
EXIV2API void append(Exiv2::Blob& blob, const byte* buf, uint32_t len);
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
} // namespace Exiv2
|
|
Packit Service |
21b5d1 |
|
|
Packit Service |
21b5d1 |
#endif // #ifndef IMAGE_HPP_
|