1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +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 TIFF {
class TIFFLoadingContext {
public:
enum class State {
@ -630,9 +632,11 @@ private:
Metadata m_metadata {};
};
}
TIFFImageDecoderPlugin::TIFFImageDecoderPlugin(NonnullOwnPtr<FixedMemoryStream> stream)
{
m_context = make<TIFFLoadingContext>(move(stream));
m_context = make<TIFF::TIFFLoadingContext>(move(stream));
}
bool TIFFImageDecoderPlugin::sniff(ReadonlyBytes bytes)
@ -662,10 +666,10 @@ ErrorOr<ImageFrameDescriptor> TIFFImageDecoderPlugin::frame(size_t index, Option
if (index > 0)
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");
if (m_context->state() < TIFFLoadingContext::State::FrameDecoded)
if (m_context->state() < TIFF::TIFFLoadingContext::State::FrameDecoded)
TRY(m_context->decode_frame());
return ImageFrameDescriptor { m_context->bitmap(), 0 };
@ -673,8 +677,8 @@ ErrorOr<ImageFrameDescriptor> TIFFImageDecoderPlugin::frame(size_t index, Option
}
template<typename T>
struct AK::Formatter<Gfx::TIFFLoadingContext::Rational<T>> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, Gfx::TIFFLoadingContext::Rational<T> value)
struct AK::Formatter<Gfx::TIFF::TIFFLoadingContext::Rational<T>> : Formatter<FormatString> {
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);
}