Loading...
Searching...
No Matches
jpgimage.hpp
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef JPGIMAGE_HPP_
#define JPGIMAGE_HPP_
#include "exiv2lib_export.h"
// included header files
#include "error.hpp"
#include "image.hpp"
// *****************************************************************************
// namespace extensions
namespace Exiv2 {
// *****************************************************************************
// class definitions
class EXIV2API JpegBase : public Image {
public:
void readMetadata() override;
void writeMetadata() override;
void printStructure(std::ostream& out, PrintStructureOption option, size_t depth) override;
protected:
JpegBase(ImageType type, BasicIo::UniquePtr io, bool create, const byte initData[], size_t dataSize);
virtual bool isThisType(BasicIo& iIo, bool advance) const = 0;
virtual int writeHeader(BasicIo& oIo) const = 0;
int num_color_components_{-1};
std::string sof_encoding_process_;
private:
int initImage(const byte initData[], size_t dataSize);
void doWriteMetadata(BasicIo& outIo);
[[nodiscard]] byte advanceToMarker(ErrorCode err) const;
DataBuf readNextSegment(byte marker);
};
class EXIV2API JpegImage : public JpegBase {
friend EXIV2API bool isJpegType(BasicIo& iIo, bool advance);
public:
JpegImage(BasicIo::UniquePtr io, bool create);
[[nodiscard]] std::string mimeType() const override;
[[nodiscard]] int numColorComponents() const {
return num_color_components_;
}
[[nodiscard]] std::string encodingProcess() const {
return sof_encoding_process_;
}
protected:
bool isThisType(BasicIo& iIo, bool advance) const override;
int writeHeader(BasicIo& outIo) const override;
private:
// Constant data
static const byte blank_[];
};
class EXIV2API ExvImage : public JpegBase {
friend EXIV2API bool isExvType(BasicIo& iIo, bool advance);
public:
ExvImage(BasicIo::UniquePtr io, bool create);
[[nodiscard]] std::string mimeType() const override;
protected:
bool isThisType(BasicIo& iIo, bool advance) const override;
int writeHeader(BasicIo& outIo) const override;
private:
// Constant data
static constexpr char exiv2Id_[] = "Exiv2"; // EXV identifier
static constexpr byte blank_[] = {0xff, 0x01, 'E', 'x', 'i', 'v', '2', 0xff, 0xd9}; // Minimal exiv2 file
}; // class ExvImage
// *****************************************************************************
// 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::UniquePtr newJpegInstance(BasicIo::UniquePtr io, bool create);
EXIV2API bool isJpegType(BasicIo& iIo, bool advance);
EXIV2API Image::UniquePtr newExvInstance(BasicIo::UniquePtr io, bool create);
EXIV2API bool isExvType(BasicIo& iIo, bool advance);
} // namespace Exiv2
#endif // #ifndef JPGIMAGE_HPP_
Exiv2::BasicIo
An interface for simple binary IO.
Definition basicio.hpp:35
Exiv2::BasicIo::UniquePtr
std::unique_ptr< BasicIo > UniquePtr
BasicIo auto_ptr type.
Definition basicio.hpp:38
Exiv2::ExvImage::isExvType
friend EXIV2API bool isExvType(BasicIo &iIo, bool advance)
Check if the file iIo is an EXV file.
Definition jpgimage.cpp:1055
Exiv2::ExvImage::isThisType
bool isThisType(BasicIo &iIo, bool advance) const override
Determine if the content of the BasicIo instance is of the type supported by this class.
Definition jpgimage.cpp:1044
Exiv2::ExvImage::mimeType
std::string mimeType() const override
Return the MIME type of the image.
Definition jpgimage.cpp:1027
Exiv2::ExvImage::ExvImage
ExvImage(BasicIo::UniquePtr io, bool create)
Constructor that can either open an existing EXV image or create a new image from scratch....
Definition jpgimage.cpp:1023
Exiv2::ExvImage::writeHeader
int writeHeader(BasicIo &outIo) const override
Writes the image header (aka signature) to the BasicIo instance.
Definition jpgimage.cpp:1031
Exiv2::Image::Image
Image(ImageType type, uint16_t supportedMetadata, BasicIo::UniquePtr io)
Constructor taking the image type, a bitmap of the supported metadata types and an auto-pointer that ...
Definition image.cpp:132
Exiv2::Image::io
virtual BasicIo & io() const
Return a reference to the BasicIo instance being used for Io.
Definition image.cpp:696
Exiv2::Image::UniquePtr
std::unique_ptr< Image > UniquePtr
Image auto_ptr type.
Definition image.hpp:53
Exiv2::JpegBase::writeHeader
virtual int writeHeader(BasicIo &oIo) const =0
Writes the image header (aka signature) to the BasicIo instance.
Exiv2::JpegBase::writeMetadata
void writeMetadata() override
Write metadata back to the image.
Definition jpgimage.cpp:584
Exiv2::JpegBase::sof_encoding_process_
std::string sof_encoding_process_
image encoding process
Definition jpgimage.hpp:90
Exiv2::JpegBase::num_color_components_
int num_color_components_
image number of color components
Definition jpgimage.hpp:89
Exiv2::JpegBase::JpegBase
JpegBase(ImageType type, BasicIo::UniquePtr io, bool create, const byte initData[], size_t dataSize)
Constructor that can either open an existing image or create a new image from scratch....
Definition jpgimage.cpp:121
Exiv2::JpegBase::printStructure
void printStructure(std::ostream &out, PrintStructureOption option, size_t depth) override
Print out the structure of image file.
Definition jpgimage.cpp:329
Exiv2::JpegBase::isThisType
virtual bool isThisType(BasicIo &iIo, bool advance) const =0
Determine if the content of the BasicIo instance is of the type supported by this class.
Exiv2::JpegBase::readMetadata
void readMetadata() override
Read all metadata supported by a specific image format from the image. Before this method is called,...
Definition jpgimage.cpp:156
Exiv2::JpegImage::JpegImage
JpegImage(BasicIo::UniquePtr io, bool create)
Constructor that can either open an existing Jpeg image or create a new image from scratch....
Definition jpgimage.cpp:976
Exiv2::JpegImage::mimeType
std::string mimeType() const override
Return the MIME type of the image.
Definition jpgimage.cpp:980
Exiv2::JpegImage::isJpegType
friend EXIV2API bool isJpegType(BasicIo &iIo, bool advance)
Check if the file iIo is a JPEG image.
Definition jpgimage.cpp:1008
Exiv2::JpegImage::numColorComponents
int numColorComponents() const
Get the number of color components of the JPEG Image.
Definition jpgimage.hpp:162
Exiv2::JpegImage::encodingProcess
std::string encodingProcess() const
Get the encoding process of the JPEG Image derived from the Start of Frame (SOF) markers.
Definition jpgimage.hpp:168
error.hpp
Error class for exceptions, log message class.
Exiv2
Class CrwImage to access Canon CRW images. References: The Canon RAW (CRW) File Format by Phil Harv...
Definition asfvideo.hpp:15
Exiv2::PrintStructureOption
PrintStructureOption
Options for printStructure.
Definition image.hpp:38
Exiv2::isExvType
EXIV2API bool isExvType(BasicIo &iIo, bool advance)
Check if the file iIo is an EXV file.
Definition jpgimage.cpp:1055
Exiv2::ErrorCode
ErrorCode
Complete list of all Exiv2 error codes.
Definition error.hpp:162
Exiv2::newJpegInstance
EXIV2API Image::UniquePtr newJpegInstance(BasicIo::UniquePtr io, bool create)
Create a new JpegImage instance and return an auto-pointer to it. Caller owns the returned object and...
Definition jpgimage.cpp:1000
Exiv2::newExvInstance
EXIV2API Image::UniquePtr newExvInstance(BasicIo::UniquePtr io, bool create)
Create a new ExvImage instance and return an auto-pointer to it. Caller owns the returned object and ...
Definition jpgimage.cpp:1048
Exiv2::ImageType
ImageType
Supported Image Formats.
Definition image_types.hpp:8
Exiv2::isJpegType
EXIV2API bool isJpegType(BasicIo &iIo, bool advance)
Check if the file iIo is a JPEG image.
Definition jpgimage.cpp:1008
Exiv2::DataBuf
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition types.hpp:124