2023-10-28 22:05:26 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2023, Lucas Chollet <lucas.chollet@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/MemoryStream.h>
|
2024-01-21 20:21:56 +00:00
|
|
|
#include <AK/NonnullOwnPtr.h>
|
2023-10-28 22:05:26 +00:00
|
|
|
#include <LibGfx/ImageFormats/ImageDecoder.h>
|
|
|
|
|
|
|
|
namespace Gfx {
|
|
|
|
|
2024-01-21 20:21:56 +00:00
|
|
|
class ExifMetadata;
|
|
|
|
|
2024-01-12 03:34:39 +00:00
|
|
|
// This is a link to the main TIFF specification from 1992
|
2023-10-28 22:05:26 +00:00
|
|
|
// https://www.itu.int/itudoc/itu-t/com16/tiff-fx/docs/tiff6.pdf
|
|
|
|
|
2024-01-12 03:34:39 +00:00
|
|
|
// First TIFF Technical notes from 1995
|
|
|
|
// https://www.awaresystems.be/imaging/tiff/specification/TIFFPM6.pdf
|
|
|
|
|
2024-01-19 03:44:53 +00:00
|
|
|
// Second TIFF Technical notes from 1995
|
|
|
|
// The document is the second (and current) specification for embedded JPEGs in TIFF images.
|
|
|
|
// https://www.awaresystems.be/imaging/tiff/specification/TIFFTechNote2.txt
|
|
|
|
|
2024-01-12 03:59:41 +00:00
|
|
|
// This is also compatible with Exif as it is, basically, another set of TIFF tags:
|
|
|
|
// The spec is named "Exchangeable image file format for digital still cameras: Exif Version 3.0"
|
|
|
|
// And it can be found at https://www.cipa.jp/e/std/std-sec.html
|
|
|
|
|
2023-11-12 23:19:19 +00:00
|
|
|
namespace TIFF {
|
2023-10-28 22:05:26 +00:00
|
|
|
class TIFFLoadingContext;
|
2023-11-12 23:19:19 +00:00
|
|
|
}
|
2023-10-28 22:05:26 +00:00
|
|
|
|
|
|
|
class TIFFImageDecoderPlugin : public ImageDecoderPlugin {
|
|
|
|
public:
|
|
|
|
static bool sniff(ReadonlyBytes);
|
|
|
|
static ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> create(ReadonlyBytes);
|
2024-01-21 20:21:56 +00:00
|
|
|
static ErrorOr<NonnullOwnPtr<ExifMetadata>> read_exif_metadata(ReadonlyBytes);
|
2023-10-28 22:05:26 +00:00
|
|
|
|
2024-06-16 08:38:35 +00:00
|
|
|
virtual ~TIFFImageDecoderPlugin() override;
|
2023-10-28 22:05:26 +00:00
|
|
|
|
|
|
|
virtual IntSize size() override;
|
|
|
|
|
|
|
|
virtual ErrorOr<ImageFrameDescriptor> frame(size_t index, Optional<IntSize> ideal_size = {}) override;
|
|
|
|
|
2024-01-10 02:54:51 +00:00
|
|
|
virtual Optional<Metadata const&> metadata() override;
|
2023-11-29 02:16:43 +00:00
|
|
|
virtual ErrorOr<Optional<ReadonlyBytes>> icc_data() override;
|
|
|
|
|
2023-10-28 22:05:26 +00:00
|
|
|
private:
|
|
|
|
TIFFImageDecoderPlugin(NonnullOwnPtr<FixedMemoryStream>);
|
|
|
|
|
2023-11-12 23:19:19 +00:00
|
|
|
OwnPtr<TIFF::TIFFLoadingContext> m_context;
|
2023-10-28 22:05:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|