Exiv2
preview.hpp
Go to the documentation of this file.
1 // ***************************************************************** -*- C++ -*-
2 /*
3  * Copyright (C) 2004-2018 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  */
27 #ifndef PREVIEW_HPP_
28 #define PREVIEW_HPP_
29 
30 // *****************************************************************************
31 #include "exiv2lib_export.h"
32 
33 #include "image.hpp"
34 
35 // *****************************************************************************
36 // namespace extensions
37 namespace Exiv2 {
38 
39 // *****************************************************************************
40 // class definitions
41 
43  typedef int PreviewId;
44 
48  struct EXIV2API PreviewProperties {
53 #ifdef EXV_UNICODE_PATH
54  std::wstring wextension_;
56 #endif
57  uint32_t size_;
60  uint32_t width_;
62  uint32_t height_;
65  };
66 
68  typedef std::vector<PreviewProperties> PreviewPropertiesList;
69 
73  class EXIV2API PreviewImage {
74  friend class PreviewManager;
75  public:
77 
78  PreviewImage(const PreviewImage& rhs);
81  ~PreviewImage();
83 
85 
86  PreviewImage& operator=(const PreviewImage& rhs);
89 
91 
92 
96  DataBuf copy() const;
100  const byte* pData() const;
104  uint32_t size() const;
115  long writeFile(const std::string& path) const;
116 #ifdef EXV_UNICODE_PATH
117 
121  long writeFile(const std::wstring& wpath) const;
122 #endif
123 
127  std::string mimeType() const;
132  std::string extension() const;
133 #ifdef EXV_UNICODE_PATH
134 
139  std::wstring wextension() const;
140 #endif
141 
144  uint32_t width() const;
148  uint32_t height() const;
152  PreviewId id() const;
154 
155  private:
157  PreviewImage(const PreviewProperties& properties, DataBuf data);
158 
159  PreviewProperties properties_;
160  byte* pData_;
161  uint32_t size_;
162 
163  }; // class PreviewImage
164 
168  class EXIV2API PreviewManager {
169  public:
171 
172  explicit PreviewManager(const Image& image);
175 
177 
178 
183  PreviewPropertiesList getPreviewProperties() const;
187  PreviewImage getPreviewImage(const PreviewProperties& properties) const;
189 
190  private:
191  const Image& image_;
192 
193  }; // class PreviewManager
194 } // namespace Exiv2
195 
196 #endif // #ifndef PREVIEW_HPP_
std::vector< PreviewProperties > PreviewPropertiesList
Container type to hold all preview images metadata.
Definition: preview.hpp:68
EXIV2API long writeFile(const DataBuf &buf, const std::string &path)
Write DataBuf buf to file path.
Definition: basicio.cpp:2702
PreviewId id_
Identifies type of preview image.
Definition: preview.hpp:64
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:204
Class for extracting preview images from image metadata.
Definition: preview.hpp:168
Preview image properties.
Definition: preview.hpp:48
uint8_t byte
1 byte unsigned integer type.
Definition: types.hpp:105
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition: image.hpp:81
std::string mimeType_
Preview image mime type.
Definition: preview.hpp:50
int PreviewId
Type of preview image.
Definition: preview.hpp:43
uint32_t width_
Preview image width in pixels or 0 for unknown width.
Definition: preview.hpp:60
std::string extension_
Preview image extension.
Definition: preview.hpp:52
Class that holds preview image properties and data buffer.
Definition: preview.hpp:73
IPTC string type.
Definition: types.hpp:147
uint32_t height_
Preview image height in pixels or 0 for unknown height.
Definition: preview.hpp:62
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36