23#include "rawspeedconfig.h"
61 ThrowTPE(
"Error reading TIFF structure. Unknown Type 0x%x encountered.",
68 ThrowTPE(
"integer overflow in size calculation.");
84 if constexpr ((
false)) {
94 data.setPosition(data_offset);
95 (void)
data.check(byte_size);
108 ThrowTPE(
"integer overflow in size calculation.");
112 if (
data.getSize() != bytesize)
113 ThrowTPE(
"data set larger than entry size given");
122 data(mirror.begin(), mirror.end()) {
181 ThrowTPE(
"Wrong type %u encountered. Expected Byte on 0x%x",
182 static_cast<unsigned>(
type),
static_cast<unsigned>(
tag));
184 return data.peekByte(index);
189 ThrowTPE(
"Wrong type %u encountered. Expected Short or Undefined on 0x%x",
190 static_cast<unsigned>(
type),
static_cast<unsigned>(
tag));
197 ThrowTPE(
"Wrong type %u encountered. Expected Short or Undefined on 0x%x",
198 static_cast<unsigned>(
type),
static_cast<unsigned>(
tag));
216 ThrowTPE(
"Wrong type %u encountered. Expected Long, Offset, Rational or "
218 static_cast<unsigned>(
type),
static_cast<unsigned>(
tag));
229 ThrowTPE(
"Wrong type %u encountered. Expected SLong or Undefined on 0x%x",
230 static_cast<unsigned>(
type),
static_cast<unsigned>(
tag));
237 ThrowTPE(
"Wrong type 0x%x encountered. Expected Rational",
238 static_cast<unsigned>(
type));
242 return {
getU32(index), 1};
244 auto a =
getU32(index * 2);
245 auto b =
getU32((index * 2) + 1);
251 ThrowTPE(
"Wrong type 0x%x encountered. Expected SRational",
252 static_cast<unsigned>(
type));
256 return {
getI32(index), 1};
258 auto a =
getI32(index * 2);
259 auto b =
getI32((index * 2) + 1);
265 ThrowTPE(
"Wrong type 0x%x encountered. Expected Float or something "
266 "convertible on 0x%x",
267 static_cast<unsigned>(
type),
static_cast<unsigned>(
tag));
275 return data.peek<
float>(index);
278 return static_cast<float>(
getU32(index));
281 return static_cast<float>(
getI32(index));
284 return r.den ?
static_cast<float>(r) : 0.0F;
288 return r.den ?
static_cast<float>(r) : 0.0F;
298 ThrowTPE(
"Wrong type 0x%x encountered. Expected Ascii or Byte",
299 static_cast<unsigned>(
type));
303 const auto* termIter = std::find(tmp.
begin(), tmp.
end(),
'\0');
304 return {
reinterpret_cast<const char*
>(tmp.
begin()),
305 reinterpret_cast<const char*
>(termIter)};
318 ThrowTPE(
"Internal error in TiffIFD data structure.");
assert(dim.area() >=area)
const uint8_t * begin() const
const uint8_t * end() const
ByteStream getSubStream(size_type offset, size_type size_) const
void skipBytes(size_type nbytes)
size_type getPosition() const
DataBuffer getRootIfdData() const
int16_t getI16(uint32_t index=0) const
bool RAWSPEED_READONLY isSRational() const
NotARational< uint32_t > getRational(uint32_t index=0) const
float getFloat(uint32_t index=0) const
uint32_t getU32(uint32_t index=0) const
bool RAWSPEED_READONLY isInt() const
bool RAWSPEED_READONLY isString() const
std::string getString() const
bool RAWSPEED_READONLY isFloat() const
NotARational< int32_t > getSRational(uint32_t index=0) const
uint16_t getU16(uint32_t index=0) const
uint8_t getByte(uint32_t index=0) const
TiffEntry(TiffIFD *parent, TiffTag tag, TiffDataType type, uint32_t count, ByteStream data)
static const std::array< uint32_t, 14 > datashifts
void setData(ByteStream data_)
bool RAWSPEED_READONLY isRational() const
int32_t getI32(uint32_t index=0) const
virtual void anchor() const
const std::vector< uint8_t > data
void anchor() const override
TiffEntryWithData(TiffIFD *parent, TiffTag tag, TiffDataType type, uint32_t count, Buffer mirror)
const DataBuffer rootBuffer
constexpr RAWSPEED_READNONE Ttgt implicit_cast(Tsrc value)
bool RAWSPEED_READONLY isIn(const T value, const std::initializer_list< T2 > &list)