mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 14:19:48 +00:00
LibGfx/TIFF: Put the TIFFLoadingContext
class in a TIFF namespace
This commit is contained in:
parent
b78f93d0b5
commit
1d1e7abba7
Notes:
sideshowbarker
2024-07-16 22:54:10 +09:00
Author: https://github.com/LucasChollet
Commit: 1d1e7abba7
Pull-request: https://github.com/SerenityOS/serenity/pull/21918
Reviewed-by: https://github.com/nico ✅
2 changed files with 12 additions and 6 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,9 @@ namespace Gfx {
|
|||
|
||||
// https://www.itu.int/itudoc/itu-t/com16/tiff-fx/docs/tiff6.pdf
|
||||
|
||||
namespace TIFF {
|
||||
class TIFFLoadingContext;
|
||||
}
|
||||
|
||||
class TIFFImageDecoderPlugin : public ImageDecoderPlugin {
|
||||
public:
|
||||
|
@ -29,7 +31,7 @@ public:
|
|||
private:
|
||||
TIFFImageDecoderPlugin(NonnullOwnPtr<FixedMemoryStream>);
|
||||
|
||||
OwnPtr<TIFFLoadingContext> m_context;
|
||||
OwnPtr<TIFF::TIFFLoadingContext> m_context;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue