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#pragma once
27
28#include "common/image.h"
29#include "common/mipmap_cache.h"
30
31#include <ciso646>
32
33#if defined(_LIBCPP_VERSION)
34#include <memory>
35#else
36#include <tr1/memory>
37#endif
38
39#include <OpenEXR/ImfChannelList.h>
40#include <OpenEXR/ImfFrameBuffer.h>
41#include <OpenEXR/ImfInputFile.h>
42#include <OpenEXR/ImfStandardAttributes.h>
43#include <OpenEXR/ImfTestFile.h>
44#include <OpenEXR/ImfTiledInputFile.h>
45
46#ifdef OPENEXR_IMF_INTERNAL_NAMESPACE
47#define IMF_NS OPENEXR_IMF_INTERNAL_NAMESPACE
48#else
49#define IMF_NS Imf
50#endif
51
52// this stores our exif data as a blob.
53
54template <typename T> struct array_deleter
55{
56 void operator()(T const *p)
57 {
58 delete[] p;
59 }
60};
61
62namespace IMF_NS
63{
64class Blob
65{
66public:
67 Blob() : size(0), data((uint8_t *)NULL)
68 {
69 }
70
71 Blob(uint32_t _size, uint8_t *_data) : size(_size)
72 {
73 uint8_t *tmp_ptr = new uint8_t[_size];
74 memcpy(tmp_ptr, _data, _size);
75 data.reset(tmp_ptr, array_deleter<uint8_t>());
76 }
77
78 uint32_t size;
79#if defined(_LIBCPP_VERSION)
80 std::shared_ptr<uint8_t> data;
81#else
82 std::tr1::shared_ptr<uint8_t> data;
83#endif
84};
85
86
87typedef IMF_NS::TypedAttribute<IMF_NS::Blob> BlobAttribute;
88template <> const char *BlobAttribute::staticTypeName()
89{
90 return "blob";
91}
92template <> void BlobAttribute::writeValueTo(OStream &os, int version) const
93{
94 Xdr::write<StreamIO>(os, _value.size);
95 Xdr::write<StreamIO>(os, (char *)(_value.data.get()), _value.size);
96}
97
98template <> void BlobAttribute::readValueFrom(IStream &is, int size, int version)
99{
100 Xdr::read<StreamIO>(is, _value.size);
101 _value.data.reset(new uint8_t[_value.size], array_deleter<uint8_t>());
102 Xdr::read<StreamIO>(is, (char *)(_value.data.get()), _value.size);
103}
104}
105
106// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh
107// vim: shiftwidth=2 expandtab tabstop=2 cindent
108// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-space on;
static const dt_aligned_pixel_simd_t const dt_adaptation_t const float p
Definition chromatic_adaptation.h:315
Definition imageio_exr.hh:65
Blob()
Definition imageio_exr.hh:67
std::tr1::shared_ptr< uint8_t > data
Definition imageio_exr.hh:82
uint32_t size
Definition imageio_exr.hh:78
Blob(uint32_t _size, uint8_t *_data)
Definition imageio_exr.hh:71
#define IMF_NS
Definition imageio_exr.hh:49
size_t size
Definition mipmap_cache.c:3
Imf ::TypedAttribute< Imf ::Blob > BlobAttribute
Definition imageio_exr.hh:87
Definition imageio_exr.hh:55
void operator()(T const *p)
Definition imageio_exr.hh:56