|
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 |
/*
|
|
Packit |
01d647 |
File: jp2image.cpp
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
#ifndef JP2IMAGE_HPP_
|
|
Packit |
01d647 |
#define JP2IMAGE_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 JPEG-2000 to the supported image formats
|
|
Packit |
01d647 |
namespace ImageType
|
|
Packit |
01d647 |
{
|
|
Packit |
01d647 |
const int jp2 = 15; //!< JPEG-2000 image type
|
|
Packit |
01d647 |
}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Class to access JPEG-2000 images.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
class EXIV2API Jp2Image : public Image {
|
|
Packit |
01d647 |
public:
|
|
Packit |
01d647 |
//! @name Creators
|
|
Packit |
01d647 |
//@{
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Constructor to open a JPEG-2000 image. Since the
|
|
Packit |
01d647 |
constructor can not return a result, callers should check the
|
|
Packit |
01d647 |
good() method after object construction to determine success
|
|
Packit |
01d647 |
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 |
Jp2Image(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 |
@brief Todo: Not supported yet(?). Calling this function will throw
|
|
Packit |
01d647 |
an instance of Error(kerInvalidSettingForImage).
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
void setComment(const std::string& comment);
|
|
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 |
Jp2Image(const Jp2Image& rhs);
|
|
Packit |
01d647 |
//! Assignment operator
|
|
Packit |
01d647 |
Jp2Image& operator=(const Jp2Image& 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 |
@param oIo BasicIo instance to write to (a temporary location).
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
@return 4 if opening or writing to the associated BasicIo fails
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
void doWriteMetadata(BasicIo& oIo);
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief reformats the Jp2Header to store iccProfile
|
|
Packit |
01d647 |
@param oldData DataBufRef to data in the file.
|
|
Packit |
01d647 |
@param newData DataBufRef with updated data
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
void encodeJp2Header(const DataBuf& oldData,DataBuf& newData);
|
|
Packit |
01d647 |
//@}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
}; // class Jp2Image
|
|
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 Jp2Image 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 newJp2Instance(BasicIo::AutoPtr io, bool create);
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! Check if the file iIo is a JPEG-2000 image.
|
|
Packit |
01d647 |
EXIV2API bool isJp2Type(BasicIo& iIo, bool advance);
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
} // namespace Exiv2
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
#endif // #ifndef JP2IMAGE_HPP_
|