bmffimage.hpp
// ***************************************************************** -*- C++ -*-
/*
* Copyright (C) 2021 Exiv2 authors
* This program is part of the Exiv2 distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
*/
#pragma once
// *****************************************************************************
#include "exiv2lib_export.h"
// included header files
#include "image.hpp"
#include "iostream"
// *****************************************************************************
// namespace extensions
namespace Exiv2
{
EXIV2API bool enableBMFF(bool enable = true);
}
#ifdef EXV_ENABLE_BMFF
namespace Exiv2
{
struct Iloc
{
Iloc(uint32_t ID = 0, uint32_t start = 0, uint32_t length = 0) : ID_(ID), start_(start), length_(length){};
virtual ~Iloc(){};
uint32_t ID_;
uint32_t start_;
uint32_t length_;
std::string toString() const;
}; // class Iloc
// *****************************************************************************
// class definitions
// Add Base Media File Format to the supported image formats
namespace ImageType
{
const int bmff = 19;
}
class EXIV2API BmffImage : public Image
{
public:
BmffImage(BasicIo::AutoPtr io, bool create);
void parseTiff(uint32_t root_tag, uint64_t length);
void parseTiff(uint32_t root_tag, uint64_t length,uint64_t start);
void parseXmp(uint64_t length,uint64_t start);
void parseCr3Preview(DataBuf &data,
std::ostream &out,
bool bTrace,
uint8_t version,
uint32_t width_offset,
uint32_t height_offset,
uint32_t size_offset,
uint32_t relative_position);
void readMetadata() /* override */;
void writeMetadata() /* override */;
void setComment(const std::string& comment) /* override */;
void printStructure(std::ostream& out, Exiv2::PrintStructureOption option,int depth);
std::string mimeType() const /* override */;
int pixelWidth() const;
int pixelHeight() const;
Exiv2::ByteOrder endian_ ;
private:
void openOrThrow();
long boxHandler(std::ostream& out, Exiv2::PrintStructureOption option,
const long pbox_end, int depth);
std::string indent(int i)
{
return std::string(2*i,' ');
}
uint32_t fileType_;
std::set<uint64_t> visits_;
uint64_t visits_max_;
uint16_t unknownID_; // 0xffff
uint16_t exifID_;
uint16_t xmpID_;
std::map<uint32_t, Iloc> ilocs_;
bool bReadMetadata_;
std::string toAscii(long n);
std::string boxName(uint32_t box);
bool superBox(uint32_t box);
bool fullBox(uint32_t box);
std::string uuidName(Exiv2::DataBuf& uuid);
}; // class BmffImage
// *****************************************************************************
// template, inline and free functions
// These could be static private functions on Image subclasses but then
// ImageFactory needs to be made a friend.
EXIV2API Image::AutoPtr newBmffInstance(BasicIo::AutoPtr io, bool create);
EXIV2API bool isBmffType(BasicIo& iIo, bool advance);
} // namespace Exiv2
#endif // EXV_ENABLE_BMFF
Exiv2::BasicIo
An interface for simple binary IO.
Definition: basicio.hpp:55
Exiv2::BasicIo::AutoPtr
std::auto_ptr< BasicIo > AutoPtr
BasicIo auto_ptr type.
Definition: basicio.hpp:58
Exiv2::BmffImage
Class to access BMFF images.
Definition: bmffimage.hpp:65
Exiv2::BmffImage::setComment
void setComment(const std::string &comment)
Set the image comment. The new comment is not written to the image until the writeMetadata() method i...
Exiv2::BmffImage::writeMetadata
void writeMetadata()
Write metadata back to the image.
Exiv2::BmffImage::parseCr3Preview
void parseCr3Preview(DataBuf &data, std::ostream &out, bool bTrace, uint8_t version, uint32_t width_offset, uint32_t height_offset, uint32_t size_offset, uint32_t relative_position)
Parse a Canon PRVW or THMB box and add an entry to the set of native previews.
Exiv2::BmffImage::BmffImage
BmffImage(BasicIo::AutoPtr io, bool create)
Constructor to open a BMFF image. Since the constructor can not return a result, callers should check...
Exiv2::BmffImage::parseXmp
void parseXmp(uint64_t length, uint64_t start)
parse embedded xmp/xml
Exiv2::BmffImage::readMetadata
void readMetadata()
Read all metadata supported by a specific image format from the image. Before this method is called,...
Exiv2::BmffImage::printStructure
void printStructure(std::ostream &out, Exiv2::PrintStructureOption option, int depth)
Print out the structure of image file.
Exiv2::BmffImage::mimeType
std::string mimeType() const
Return the MIME type of the image.
Exiv2::BmffImage::parseTiff
void parseTiff(uint32_t root_tag, uint64_t length)
parse embedded tiff file (Exif metadata)
Exiv2::DataBuf
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:193
Exiv2::Image
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition: image.hpp:78
Exiv2::Image::AutoPtr
std::auto_ptr< Image > AutoPtr
Image auto_ptr type.
Definition: image.hpp:81
Exiv2::ImageType::bmff
const int bmff
BMFF (bmff) image type (see class BMFF)
Definition: bmffimage.hpp:58
Exiv2
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
Exiv2::PrintStructureOption
PrintStructureOption
Options for printStructure.
Definition: image.hpp:64
Exiv2::version
EXIV2API const char * version()
Return the version of Exiv2 as "C" string eg "0.27.0.2".
Definition: version.cpp:103
Exiv2::newBmffInstance
EXIV2API Image::AutoPtr newBmffInstance(BasicIo::AutoPtr io, bool create)
Create a new BMFF instance and return an auto-pointer to it. Caller owns the returned object and the ...
Exiv2::comment
@ comment
Exiv2 type for the Exif user comment.
Definition: types.hpp:139
Exiv2::ByteOrder
ByteOrder
Type to express the byte order (little or big endian)
Definition: types.hpp:102
Exiv2::isBmffType
EXIV2API bool isBmffType(BasicIo &iIo, bool advance)
Check if the file iIo is a BMFF image.
Exiv2::Iloc
Definition: bmffimage.hpp:41