载入中...
搜索中...
未找到
SourceTiff.cpp
浏览该文件的文档.
39 for (unsigned i = 0; i < width; ++i, ++bit) code = (code << 1) | ((source[bit / 8] >> (7 - bit % 8)) & 1);
81Result<TiffPixels> decodeTiffRgba8(std::span<const std::uint8_t> bytes, std::uint64_t maximumDecodedBytes) {
83 if (bytes.size() < 8 || !((bytes[0] == 'I' && bytes[1] == 'I') || (bytes[0] == 'M' && bytes[1] == 'M')))
88 if (ifd < 8 || count > 4096 || std::uint64_t(ifd) + 2 + 12ull * count + 4 > bytes.size()) throw Invalid{};
91 const auto at = ifd + 2 + i * 12, id = r.read(at, 2), type = r.read(at + 2, 2), n = r.read(at + 4, 4);
111 for (unsigned i = 0; i < t.count; ++i) result.push_back(r.read(t.offset + std::size_t(i) * step, step));
119 const auto w = scalar(256, 0), h = scalar(257, 0), channels = scalar(277, 1), compression = scalar(259, 1);
120 const auto rows = scalar(278, UINT32_MAX), orientation = scalar(274, 1), predictor = scalar(317, 1);
121 if (!w || !h || !rows || maximumDecodedBytes < 24 || std::uint64_t(w) * h > (maximumDecodedBytes - 24) / 4)
123 if (scalar(262, 0) != 2 || scalar(284, 1) != 1 || (channels != 3 && channels != 4) || orientation < 1 ||
132 if (channels == 4 && (extra.size() != 1 || (extra[0] != 0 && extra[0] != 2))) throw Unsupported{};
134 if (compression != 1 && compression != 5 && compression != 8 && compression != 32946) throw Unsupported{};
136 if (offsets.size() != (std::uint64_t(h) + rows - 1) / rows || sizes.size() != offsets.size()) throw Invalid{};
183 "unsupported TIFF layout; requires unsigned 8/16-bit RGB(A) strips with raw, LZW or Deflate compression",
187 DiagnosticCode::ParseError, "malformed TIFF or decoded image budget exceeded", {}, {}, "asset.image.tiff"));
std::map< std::string, std::vector< Key >, std::less<> > channels
Definition AnimCurveLibrary.cpp:19
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Definition SourceBc3.cpp:5
Result< TiffPixels > decodeTiffRgba8(std::span< const std::uint8_t > bytes, std::uint64_t maximumDecodedBytes)
Decode bounded strip-based unsigned RGB TIFF (8/16 bits, raw/LZW/Deflate).
Definition SourceTiff.cpp:81
constexpr HexDirection next(HexDirection d) noexcept
The next direction clockwise (NW wraps to NE).
Definition HexMetrics.h:76
@ Unsupported
@ ParseError
Owning top-down RGB(A) TIFF pixels; unspecified fourth samples remain alpha data.
Definition SourceTiff.h:10