|
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 webpimage.hpp
|
|
Packit |
01d647 |
@brief An Image subclass to support WEBP image files
|
|
Packit |
01d647 |
@author Ben Touchette
|
|
Packit |
01d647 |
draekko.software+exiv2@gmail.com
|
|
Packit |
01d647 |
@date 29-Jul-16
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
#ifndef WEBPIMAGE_HPP
|
|
Packit |
01d647 |
#define WEBPIMAGE_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 |
// class definitions
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
// Add WEBP to the supported image formats
|
|
Packit |
01d647 |
namespace ImageType {
|
|
Packit |
01d647 |
const int webp = 23; //!< Treating webp as an image type>
|
|
Packit |
01d647 |
}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Class to access WEBP video files.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
class EXIV2API WebPImage:public Image
|
|
Packit |
01d647 |
{
|
|
Packit |
01d647 |
public:
|
|
Packit |
01d647 |
//! @name Creators
|
|
Packit |
01d647 |
//@{
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Constructor for a WebP video. Since the constructor
|
|
Packit |
01d647 |
can not return a result, callers should check the good() method
|
|
Packit |
01d647 |
after object 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 |
*/
|
|
Packit |
01d647 |
WebPImage(BasicIo::AutoPtr io);
|
|
Packit |
01d647 |
//@}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! @name Manipulators
|
|
Packit |
01d647 |
//@{
|
|
Packit |
01d647 |
void readMetadata();
|
|
Packit |
01d647 |
void writeMetadata();
|
|
Packit |
01d647 |
void printStructure(std::ostream& out, PrintStructureOption option,int depth);
|
|
Packit |
01d647 |
//@}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Not supported. Calling this function will throw an Error(kerInvalidSettingForImage).
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
void setComment(const std::string& comment);
|
|
Packit |
01d647 |
void setIptcData(const IptcData& /*iptcData*/);
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! @name Accessors
|
|
Packit |
01d647 |
//@{
|
|
Packit |
01d647 |
std::string mimeType() const;
|
|
Packit |
01d647 |
//@}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
private:
|
|
Packit |
01d647 |
void doWriteMetadata(BasicIo& outIo);
|
|
Packit |
01d647 |
//! @name NOT Implemented
|
|
Packit |
01d647 |
//@{
|
|
Packit |
01d647 |
long getHeaderOffset(byte *data, long data_size,
|
|
Packit |
01d647 |
byte *header, long header_size);
|
|
Packit |
01d647 |
bool equalsWebPTag(Exiv2::DataBuf& buf ,const char* str);
|
|
Packit |
01d647 |
void debugPrintHex(byte *data, long size);
|
|
Packit |
01d647 |
void decodeChunks(long filesize);
|
|
Packit |
01d647 |
void inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif,
|
|
Packit |
01d647 |
bool has_alpha, bool has_icc, int width,
|
|
Packit |
01d647 |
int height);
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! Copy constructor
|
|
Packit |
01d647 |
WebPImage(const WebPImage& rhs);
|
|
Packit |
01d647 |
//! Assignment operator
|
|
Packit |
01d647 |
WebPImage& operator=(const WebPImage& rhs);
|
|
Packit |
01d647 |
//@}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
private:
|
|
Packit |
01d647 |
const static byte WEBP_PAD_ODD;
|
|
Packit |
01d647 |
const static int WEBP_TAG_SIZE;
|
|
Packit |
01d647 |
const static int WEBP_VP8X_ICC_BIT;
|
|
Packit |
01d647 |
const static int WEBP_VP8X_ALPHA_BIT;
|
|
Packit |
01d647 |
const static int WEBP_VP8X_EXIF_BIT;
|
|
Packit |
01d647 |
const static int WEBP_VP8X_XMP_BIT;
|
|
Packit |
01d647 |
const static char* WEBP_CHUNK_HEADER_VP8X;
|
|
Packit |
01d647 |
const static char* WEBP_CHUNK_HEADER_VP8L;
|
|
Packit |
01d647 |
const static char* WEBP_CHUNK_HEADER_VP8;
|
|
Packit |
01d647 |
const static char* WEBP_CHUNK_HEADER_ANMF;
|
|
Packit |
01d647 |
const static char* WEBP_CHUNK_HEADER_ANIM;
|
|
Packit |
01d647 |
const static char* WEBP_CHUNK_HEADER_ICCP;
|
|
Packit |
01d647 |
const static char* WEBP_CHUNK_HEADER_EXIF;
|
|
Packit |
01d647 |
const static char* WEBP_CHUNK_HEADER_XMP;
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
}; //Class WebPImage
|
|
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 WebPImage 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 newWebPInstance(BasicIo::AutoPtr io, bool create);
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! Check if the file iIo is a WebP Video.
|
|
Packit |
01d647 |
EXIV2API bool isWebPType(BasicIo& iIo, bool advance);
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
} // namespace Exiv2
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
#endif // WEBPIMAGE_HPP
|