|
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 preview.hpp
|
|
Packit |
01d647 |
@brief Classes to access all preview images embedded in an image.
|
|
Packit |
01d647 |
@author Vladimir Nadvornik (vn)
|
|
Packit |
01d647 |
nadvornik@suse.cz
|
|
Packit |
01d647 |
@date 18-Sep-08, vn: created
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
#ifndef PREVIEW_HPP_
|
|
Packit |
01d647 |
#define PREVIEW_HPP_
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
// *****************************************************************************
|
|
Packit |
01d647 |
#include "exiv2lib_export.h"
|
|
Packit |
01d647 |
|
|
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 |
//! Type of preview image.
|
|
Packit |
01d647 |
typedef int PreviewId;
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Preview image properties.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
struct EXIV2API PreviewProperties {
|
|
Packit |
01d647 |
//! Preview image mime type.
|
|
Packit |
01d647 |
std::string mimeType_;
|
|
Packit |
01d647 |
//! Preview image extension.
|
|
Packit |
01d647 |
std::string extension_;
|
|
Packit |
01d647 |
#ifdef EXV_UNICODE_PATH
|
|
Packit |
01d647 |
//! Unicode preview image extension in an std::wstring
|
|
Packit |
01d647 |
std::wstring wextension_;
|
|
Packit |
01d647 |
#endif
|
|
Packit |
01d647 |
//! Preview image size in bytes.
|
|
Packit |
01d647 |
uint32_t size_;
|
|
Packit |
01d647 |
//! Preview image width in pixels or 0 for unknown width.
|
|
Packit |
01d647 |
uint32_t width_;
|
|
Packit |
01d647 |
//! Preview image height in pixels or 0 for unknown height.
|
|
Packit |
01d647 |
uint32_t height_;
|
|
Packit |
01d647 |
//! Identifies type of preview image.
|
|
Packit |
01d647 |
PreviewId id_;
|
|
Packit |
01d647 |
};
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! Container type to hold all preview images metadata.
|
|
Packit |
01d647 |
typedef std::vector<PreviewProperties> PreviewPropertiesList;
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Class that holds preview image properties and data buffer.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
class EXIV2API PreviewImage {
|
|
Packit |
01d647 |
friend class PreviewManager;
|
|
Packit |
01d647 |
public:
|
|
Packit |
01d647 |
//! @name Constructors
|
|
Packit |
01d647 |
//@{
|
|
Packit |
01d647 |
//! Copy constructor
|
|
Packit |
01d647 |
PreviewImage(const PreviewImage& rhs);
|
|
Packit |
01d647 |
//! Destructor.
|
|
Packit |
01d647 |
~PreviewImage();
|
|
Packit |
01d647 |
//@}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! @name Manipulators
|
|
Packit |
01d647 |
//@{
|
|
Packit |
01d647 |
//! Assignment operator
|
|
Packit |
01d647 |
PreviewImage& operator=(const PreviewImage& rhs);
|
|
Packit |
01d647 |
//@}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! @name Accessors
|
|
Packit |
01d647 |
//@{
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Return a copy of the preview image data. The caller owns
|
|
Packit |
01d647 |
this copy and %DataBuf ensures that it will be deleted.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
DataBuf copy() const;
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Return a pointer to the image data for read-only access.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
const byte* pData() const;
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Return the size of the preview image in bytes.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
uint32_t size() const;
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Write the thumbnail image to a file.
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
A filename extension is appended to \em path according to the image
|
|
Packit |
01d647 |
type of the preview image, so \em path should not include an extension.
|
|
Packit |
01d647 |
The function will overwrite an existing file of the same name.
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
@param path File name of the preview image without extension.
|
|
Packit |
01d647 |
@return The number of bytes written.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
long writeFile(const std::string& path) const;
|
|
Packit |
01d647 |
#ifdef EXV_UNICODE_PATH
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Like writeFile() but accepts a unicode path in an std::wstring.
|
|
Packit |
01d647 |
@note This function is only available on Windows.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
long writeFile(const std::wstring& wpath) const;
|
|
Packit |
01d647 |
#endif
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Return the MIME type of the preview image, usually either
|
|
Packit |
01d647 |
\c "image/tiff" or \c "image/jpeg".
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
std::string mimeType() const;
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Return the file extension for the format of the preview image
|
|
Packit |
01d647 |
(".tif" or ".jpg").
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
std::string extension() const;
|
|
Packit |
01d647 |
#ifdef EXV_UNICODE_PATH
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Like extension() but returns the unicode encoded extension in
|
|
Packit |
01d647 |
an std::wstring.
|
|
Packit |
01d647 |
@note This function is only available on Windows.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
std::wstring wextension() const;
|
|
Packit |
01d647 |
#endif
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Return the width of the preview image in pixels.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
uint32_t width() const;
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Return the height of the preview image in pixels.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
uint32_t height() const;
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Return the preview image type identifier.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
PreviewId id() const;
|
|
Packit |
01d647 |
//@}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
private:
|
|
Packit |
01d647 |
//! Private constructor
|
|
Packit |
01d647 |
PreviewImage(const PreviewProperties& properties, DataBuf data);
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
PreviewProperties properties_; //!< Preview image properties
|
|
Packit |
01d647 |
byte* pData_; //!< Pointer to the preview image data
|
|
Packit |
01d647 |
uint32_t size_; //!< Size of the preview image data
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
}; // class PreviewImage
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Class for extracting preview images from image metadata.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
class EXIV2API PreviewManager {
|
|
Packit |
01d647 |
public:
|
|
Packit |
01d647 |
//! @name Constructors
|
|
Packit |
01d647 |
//@{
|
|
Packit |
01d647 |
//! Constructor.
|
|
Packit |
01d647 |
explicit PreviewManager(const Image& image);
|
|
Packit |
01d647 |
//@}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! @name Accessors
|
|
Packit |
01d647 |
//@{
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Return the properties of all preview images in a list
|
|
Packit |
01d647 |
sorted by preview width * height, starting with the smallest
|
|
Packit |
01d647 |
preview image.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
PreviewPropertiesList getPreviewProperties() const;
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Return the preview image for the given preview properties.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
PreviewImage getPreviewImage(const PreviewProperties& properties) const;
|
|
Packit |
01d647 |
//@}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
private:
|
|
Packit |
01d647 |
const Image& image_;
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
}; // class PreviewManager
|
|
Packit |
01d647 |
} // namespace Exiv2
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
#endif // #ifndef PREVIEW_HPP_
|