mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
LibGfx/TIFF: Teach the generator how to handle tags of type Undefined
This tag type is a bit different as even if it fits in the general definition given in the TIFF specification. That is the value will be of one specified type multiplied by a known count. Having a `Vector<Variant<u8, ...>>` will be very painful to use. So let's deviate a bit from the normal way and use a `ByteBuffer` directly instead this complicated type.
This commit is contained in:
parent
24b9d05ea8
commit
62f28d9968
2 changed files with 30 additions and 5 deletions
|
@ -346,8 +346,13 @@ private:
|
|||
|
||||
switch (type) {
|
||||
case Type::Byte:
|
||||
case Type::Undefined:
|
||||
return read_every_values.template operator()<u8>();
|
||||
case Type::Undefined: {
|
||||
Vector<Value, 1> result;
|
||||
auto buffer = TRY(ByteBuffer::create_uninitialized(count));
|
||||
TRY(m_stream->read_until_filled(buffer));
|
||||
result.append(move(buffer));
|
||||
return result;
|
||||
}
|
||||
case Type::ASCII:
|
||||
case Type::UTF8: {
|
||||
Vector<Value, 1> result;
|
||||
|
@ -397,6 +402,9 @@ private:
|
|||
if constexpr (TIFF_DEBUG) {
|
||||
if (tiff_value.size() == 1) {
|
||||
tiff_value[0].visit(
|
||||
[&](ByteBuffer& value) {
|
||||
dbgln("Read tag({}), type({}): size {}", tag, to_underlying(type), value.size());
|
||||
},
|
||||
[&](auto const& value) {
|
||||
dbgln("Read tag({}), type({}): {}", tag, to_underlying(type), value);
|
||||
});
|
||||
|
@ -404,6 +412,9 @@ private:
|
|||
dbg("Read tag({}), type({}): [", tag, to_underlying(type));
|
||||
for (u32 i = 0; i < tiff_value.size(); ++i) {
|
||||
tiff_value[i].visit(
|
||||
[&](ByteBuffer&) {
|
||||
VERIFY_NOT_REACHED();
|
||||
},
|
||||
[&](auto const& value) {
|
||||
dbg("{}", value);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue