Exiv2
preview.hpp
1// ***************************************************************** -*- C++ -*-
2/*
3 * Copyright (C) 2004-2021 Exiv2 authors
4 * This program is part of the Exiv2 distribution.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
19 */
20#ifndef PREVIEW_HPP_
21#define PREVIEW_HPP_
22
23// *****************************************************************************
24#include "exiv2lib_export.h"
25
26#include "image.hpp"
27
28// *****************************************************************************
29// namespace extensions
30namespace Exiv2 {
31
32// *****************************************************************************
33// class definitions
34
36 typedef int PreviewId;
37
41 struct EXIV2API PreviewProperties {
43 std::string mimeType_;
45 std::string extension_;
46#ifdef EXV_UNICODE_PATH
48 std::wstring wextension_;
49#endif
51 uint32_t size_;
53 uint32_t width_;
55 uint32_t height_;
58 };
59
61 typedef std::vector<PreviewProperties> PreviewPropertiesList;
62
66 class EXIV2API PreviewImage {
67 friend class PreviewManager;
68 public:
70
71
72 PreviewImage(const PreviewImage& rhs);
76
78
79
80 PreviewImage& operator=(const PreviewImage& rhs);
82
84
85
89 DataBuf copy() const;
93 const byte* pData() const;
97 uint32_t size() const;
108 long writeFile(const std::string& path) const;
109#ifdef EXV_UNICODE_PATH
114 long writeFile(const std::wstring& wpath) const;
115#endif
120 std::string mimeType() const;
125 std::string extension() const;
126#ifdef EXV_UNICODE_PATH
132 std::wstring wextension() const;
133#endif
137 uint32_t width() const;
141 uint32_t height() const;
145 PreviewId id() const;
147
148 private:
150 PreviewImage(const PreviewProperties& properties, DataBuf data);
151
152 PreviewProperties properties_;
153 byte* pData_;
154 uint32_t size_;
155
156 }; // class PreviewImage
157
161 class EXIV2API PreviewManager {
162 public:
164
165
166 explicit PreviewManager(const Image& image);
168
170
171
176 PreviewPropertiesList getPreviewProperties() const;
180 PreviewImage getPreviewImage(const PreviewProperties& properties) const;
182
183 private:
184 const Image& image_;
185
186 }; // class PreviewManager
187} // namespace Exiv2
188
189#endif // #ifndef PREVIEW_HPP_
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:193
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition: image.hpp:78
Class that holds preview image properties and data buffer.
Definition: preview.hpp:66
Class for extracting preview images from image metadata.
Definition: preview.hpp:161
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
EXIV2API long writeFile(const DataBuf &buf, const std::string &path)
Write DataBuf buf to file path.
Definition: basicio.cpp:2703
int PreviewId
Type of preview image.
Definition: preview.hpp:36
std::vector< PreviewProperties > PreviewPropertiesList
Container type to hold all preview images metadata.
Definition: preview.hpp:61
Preview image properties.
Definition: preview.hpp:41
uint32_t size_
Preview image size in bytes.
Definition: preview.hpp:51
std::string extension_
Preview image extension.
Definition: preview.hpp:45
uint32_t height_
Preview image height in pixels or 0 for unknown height.
Definition: preview.hpp:55
uint32_t width_
Preview image width in pixels or 0 for unknown width.
Definition: preview.hpp:53
PreviewId id_
Identifies type of preview image.
Definition: preview.hpp:57
std::string mimeType_
Preview image mime type.
Definition: preview.hpp:43