1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:57:44 +00:00

LibGfx/TIFF: Put the TIFFLoadingContext class in a TIFF namespace

This commit is contained in:
Lucas CHOLLET 2023-11-12 18:19:19 -05:00 committed by Sam Atkins
parent b78f93d0b5
commit 1d1e7abba7
2 changed files with 12 additions and 6 deletions

View file

@ -12,6 +12,8 @@
namespace Gfx { namespace Gfx {
namespace TIFF {
class TIFFLoadingContext { class TIFFLoadingContext {
public: public:
enum class State { enum class State {
@ -630,9 +632,11 @@ private:
Metadata m_metadata {}; Metadata m_metadata {};
}; };
}
TIFFImageDecoderPlugin::TIFFImageDecoderPlugin(NonnullOwnPtr<FixedMemoryStream> stream) TIFFImageDecoderPlugin::TIFFImageDecoderPlugin(NonnullOwnPtr<FixedMemoryStream> stream)
{ {
m_context = make<TIFFLoadingContext>(move(stream)); m_context = make<TIFF::TIFFLoadingContext>(move(stream));
} }
bool TIFFImageDecoderPlugin::sniff(ReadonlyBytes bytes) bool TIFFImageDecoderPlugin::sniff(ReadonlyBytes bytes)
@ -662,10 +666,10 @@ ErrorOr<ImageFrameDescriptor> TIFFImageDecoderPlugin::frame(size_t index, Option
if (index > 0) if (index > 0)
return Error::from_string_literal("TIFFImageDecoderPlugin: Invalid frame index"); return Error::from_string_literal("TIFFImageDecoderPlugin: Invalid frame index");
if (m_context->state() == TIFFLoadingContext::State::Error) if (m_context->state() == TIFF::TIFFLoadingContext::State::Error)
return Error::from_string_literal("TIFFImageDecoderPlugin: Decoding failed"); return Error::from_string_literal("TIFFImageDecoderPlugin: Decoding failed");
if (m_context->state() < TIFFLoadingContext::State::FrameDecoded) if (m_context->state() < TIFF::TIFFLoadingContext::State::FrameDecoded)
TRY(m_context->decode_frame()); TRY(m_context->decode_frame());
return ImageFrameDescriptor { m_context->bitmap(), 0 }; return ImageFrameDescriptor { m_context->bitmap(), 0 };
@ -673,8 +677,8 @@ ErrorOr<ImageFrameDescriptor> TIFFImageDecoderPlugin::frame(size_t index, Option
} }
template<typename T> template<typename T>
struct AK::Formatter<Gfx::TIFFLoadingContext::Rational<T>> : Formatter<FormatString> { struct AK::Formatter<Gfx::TIFF::TIFFLoadingContext::Rational<T>> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, Gfx::TIFFLoadingContext::Rational<T> value) ErrorOr<void> format(FormatBuilder& builder, Gfx::TIFF::TIFFLoadingContext::Rational<T> value)
{ {
return Formatter<FormatString>::format(builder, "{} ({}/{})"sv, static_cast<double>(value.numerator) / value.denominator, value.numerator, value.denominator); return Formatter<FormatString>::format(builder, "{} ({}/{})"sv, static_cast<double>(value.numerator) / value.denominator, value.numerator, value.denominator);
} }

View file

@ -13,7 +13,9 @@ namespace Gfx {
// https://www.itu.int/itudoc/itu-t/com16/tiff-fx/docs/tiff6.pdf // https://www.itu.int/itudoc/itu-t/com16/tiff-fx/docs/tiff6.pdf
namespace TIFF {
class TIFFLoadingContext; class TIFFLoadingContext;
}
class TIFFImageDecoderPlugin : public ImageDecoderPlugin { class TIFFImageDecoderPlugin : public ImageDecoderPlugin {
public: public:
@ -29,7 +31,7 @@ public:
private: private:
TIFFImageDecoderPlugin(NonnullOwnPtr<FixedMemoryStream>); TIFFImageDecoderPlugin(NonnullOwnPtr<FixedMemoryStream>);
OwnPtr<TIFFLoadingContext> m_context; OwnPtr<TIFF::TIFFLoadingContext> m_context;
}; };
} }