|
Packit |
01d647 |
// ***************************************************************** -*- C++ -*-
|
|
Packit |
01d647 |
/*
|
|
Packit |
01d647 |
* Copyright (C) 2004-2018 Exiv2 authors
|
|
Packit |
01d647 |
* This program is part of the Exiv2 distribution.
|
|
Packit |
01d647 |
*
|
|
Packit |
01d647 |
* This program is free software; you can redistribute it and/or
|
|
Packit |
01d647 |
* modify it under the terms of the GNU General Public License
|
|
Packit |
01d647 |
* as published by the Free Software Foundation; either version 2
|
|
Packit |
01d647 |
* of the License, or (at your option) any later version.
|
|
Packit |
01d647 |
*
|
|
Packit |
01d647 |
* This program is distributed in the hope that it will be useful,
|
|
Packit |
01d647 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
01d647 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
01d647 |
* GNU General Public License for more details.
|
|
Packit |
01d647 |
*
|
|
Packit |
01d647 |
* You should have received a copy of the GNU General Public License
|
|
Packit |
01d647 |
* along with this program; if not, write to the Free Software
|
|
Packit |
01d647 |
* Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@file pngimage.hpp
|
|
Packit |
01d647 |
@brief PNG image, implemented using the following references:
|
|
Packit |
01d647 |
PNG specification by W3C
|
|
Packit |
01d647 |
PNG tags list by Phil Harvey
|
|
Packit |
01d647 |
@author Andreas Huggel (ahu)
|
|
Packit |
01d647 |
ahuggel@gmx.net
|
|
Packit |
01d647 |
@author Gilles Caulier (cgilles)
|
|
Packit |
01d647 |
caulier dot gilles at gmail dot com
|
|
Packit |
01d647 |
@date 12-Jun-06, gc: submitted
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
#ifndef PNGIMAGE_HPP_
|
|
Packit |
01d647 |
#define PNGIMAGE_HPP_
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
// *****************************************************************************
|
|
Packit |
01d647 |
#include "exiv2lib_export.h"
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
// included header files
|
|
Packit |
01d647 |
#include "image.hpp"
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
// *****************************************************************************
|
|
Packit |
01d647 |
// namespace extensions
|
|
Packit |
01d647 |
namespace Exiv2
|
|
Packit |
01d647 |
{
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
// *****************************************************************************
|
|
Packit |
01d647 |
// class definitions
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
// Add PNG to the supported image formats
|
|
Packit |
01d647 |
namespace ImageType
|
|
Packit |
01d647 |
{
|
|
Packit |
01d647 |
const int png = 6; //!< PNG image type (see class PngImage)
|
|
Packit |
01d647 |
}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Class to access PNG images. Exif and IPTC metadata are supported
|
|
Packit |
01d647 |
directly.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
class EXIV2API PngImage : public Image {
|
|
Packit |
01d647 |
public:
|
|
Packit |
01d647 |
//! @name Creators
|
|
Packit |
01d647 |
//@{
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Constructor that can either open an existing PNG image or create
|
|
Packit |
01d647 |
a new image from scratch. If a new image is to be created, any
|
|
Packit |
01d647 |
existing data is overwritten. Since the constructor can not return
|
|
Packit |
01d647 |
a result, callers should check the good() method after object
|
|
Packit |
01d647 |
construction to determine success or failure.
|
|
Packit |
01d647 |
@param io An auto-pointer that owns a BasicIo instance used for
|
|
Packit |
01d647 |
reading and writing image metadata. \b Important: The constructor
|
|
Packit |
01d647 |
takes ownership of the passed in BasicIo instance through the
|
|
Packit |
01d647 |
auto-pointer. Callers should not continue to use the BasicIo
|
|
Packit |
01d647 |
instance after it is passed to this method. Use the Image::io()
|
|
Packit |
01d647 |
method to get a temporary reference.
|
|
Packit |
01d647 |
@param create Specifies if an existing image should be read (false)
|
|
Packit |
01d647 |
or if a new file should be created (true).
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
PngImage(BasicIo::AutoPtr io, bool create);
|
|
Packit |
01d647 |
//@}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! @name Manipulators
|
|
Packit |
01d647 |
//@{
|
|
Packit |
01d647 |
void readMetadata();
|
|
Packit |
01d647 |
void writeMetadata();
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Print out the structure of image file.
|
|
Packit |
01d647 |
@throw Error if reading of the file fails or the image data is
|
|
Packit |
01d647 |
not valid (does not look like data of the specific image type).
|
|
Packit |
01d647 |
@warning This function is not thread safe and intended for exiv2 -pS for debugging.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
void printStructure(std::ostream& out, PrintStructureOption option,int depth);
|
|
Packit |
01d647 |
//@}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! @name Accessors
|
|
Packit |
01d647 |
//@{
|
|
Packit |
01d647 |
std::string mimeType() const;
|
|
Packit |
01d647 |
//@}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
private:
|
|
Packit |
01d647 |
//! @name NOT implemented
|
|
Packit |
01d647 |
//@{
|
|
Packit |
01d647 |
//! Copy constructor
|
|
Packit |
01d647 |
PngImage(const PngImage& rhs);
|
|
Packit |
01d647 |
//! Assignment operator
|
|
Packit |
01d647 |
PngImage& operator=(const PngImage& rhs);
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Provides the main implementation of writeMetadata() by
|
|
Packit |
01d647 |
writing all buffered metadata to the provided BasicIo.
|
|
Packit |
01d647 |
@throw Error on input-output errors or when the image data is not valid.
|
|
Packit |
01d647 |
@param oIo BasicIo instance to write to (a temporary location).
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
void doWriteMetadata(BasicIo& oIo);
|
|
Packit |
01d647 |
//@}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
std::string profileName_;
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
}; // class PngImage
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
// *****************************************************************************
|
|
Packit |
01d647 |
// template, inline and free functions
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
// These could be static private functions on Image subclasses but then
|
|
Packit |
01d647 |
// ImageFactory needs to be made a friend.
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Create a new PngImage instance and return an auto-pointer to it.
|
|
Packit |
01d647 |
Caller owns the returned object and the auto-pointer ensures that
|
|
Packit |
01d647 |
it will be deleted.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
EXIV2API Image::AutoPtr newPngInstance(BasicIo::AutoPtr io, bool create);
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! Check if the file iIo is a PNG image.
|
|
Packit |
01d647 |
EXIV2API bool isPngType(BasicIo& iIo, bool advance);
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
} // namespace Exiv2
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
#endif // #ifndef PNGIMAGE_HPP_
|