Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
imageio_exr.hh
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2010 Henrik Andersson.
4 Copyright (C) 2010-2013 johannes hanika.
5 Copyright (C) 2012 Richard Wonka.
6 Copyright (C) 2012, 2014, 2016 Tobias Ellinghaus.
7 Copyright (C) 2013 Jean-Sébastien Pédron.
8 Copyright (C) 2013 parafin.
9 Copyright (C) 2016 Roman Lebedev.
10 Copyright (C) 2020 Pascal Obry.
11
12 darktable is free software: you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation, either version 3 of the License, or
15 (at your option) any later version.
16
17 darktable is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with darktable. If not, see <http://www.gnu.org/licenses/>.
24*/
25
26#ifndef DT_IMAGEIO_IMAGEIO_EXR_HH
27#define DT_IMAGEIO_IMAGEIO_EXR_HH
28
29#include "common/image.h"
30#include "caches/mipmap_cache.h"
31
32#include <ciso646>
33
34#if defined(_LIBCPP_VERSION)
35#include <memory>
36#else
37#include <tr1/memory>
38#endif
39
40#include <OpenEXR/ImfChannelList.h>
41#include <OpenEXR/ImfFrameBuffer.h>
42#include <OpenEXR/ImfInputFile.h>
43#include <OpenEXR/ImfStandardAttributes.h>
44#include <OpenEXR/ImfTestFile.h>
45#include <OpenEXR/ImfTiledInputFile.h>
46
47#ifdef OPENEXR_IMF_INTERNAL_NAMESPACE
48#define IMF_NS OPENEXR_IMF_INTERNAL_NAMESPACE
49#else
50#define IMF_NS Imf
51#endif
52
53// this stores our exif data as a blob.
54
55template <typename T> struct array_deleter
56{
57 void operator()(T const *p)
58 {
59 delete[] p;
60 }
61};
62
63namespace IMF_NS
64{
65class Blob
66{
67public:
68 Blob() : size(0), data((uint8_t *)NULL)
69 {
70 }
71
72 Blob(uint32_t _size, uint8_t *_data) : size(_size)
73 {
74 uint8_t *tmp_ptr = new uint8_t[_size];
75 memcpy(tmp_ptr, _data, _size);
76 data.reset(tmp_ptr, array_deleter<uint8_t>());
77 }
78
79 uint32_t size;
80#if defined(_LIBCPP_VERSION)
81 std::shared_ptr<uint8_t> data;
82#else
83 std::tr1::shared_ptr<uint8_t> data;
84#endif
85};
86
87
88typedef IMF_NS::TypedAttribute<IMF_NS::Blob> BlobAttribute;
89template <> const char *BlobAttribute::staticTypeName()
90{
91 return "blob";
92}
93template <> void BlobAttribute::writeValueTo(OStream &os, int version) const
94{
95 Xdr::write<StreamIO>(os, _value.size);
96 Xdr::write<StreamIO>(os, (char *)(_value.data.get()), _value.size);
97}
98
99template <> void BlobAttribute::readValueFrom(IStream &is, int size, int version)
100{
101 Xdr::read<StreamIO>(is, _value.size);
102 _value.data.reset(new uint8_t[_value.size], array_deleter<uint8_t>());
103 Xdr::read<StreamIO>(is, (char *)(_value.data.get()), _value.size);
104}
105}
106
107#endif // DT_IMAGEIO_IMAGEIO_EXR_HH
108
109// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh
110// vim: shiftwidth=2 expandtab tabstop=2 cindent
111// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-space on;
std::tr1::shared_ptr< uint8_t > data
uint32_t size
Blob(uint32_t _size, uint8_t *_data)
#define IMF_NS
size_t size
Definition mipmap_cache.c:3
Imf ::TypedAttribute< Imf ::Blob > BlobAttribute
void operator()(T const *p)