载入中...
搜索中...
未找到
SourcePng.cpp
浏览该文件的文档.
18 Diagnostic::error(DiagnosticCode::InvalidArgument, "invalid PNG pixel dimensions or encoding budget", {},
25 const std::uint64_t row = std::uint64_t(width) * 4, total = pixels.size() + std::uint64_t(height);
71 if (b[1] != 0 || (b[2] != 2 && b[2] != 10) || (b[16] != 24 && b[16] != 32) || (b[17] & 192) != 0 ||
73 return fail(DiagnosticCode::Unsupported, "TGA requires non-interleaved 24/32-bit true-color raw or RLE pixels");
128Result<std::vector<std::uint8_t>> decodeBc3Rgba8(std::span<const std::uint8_t> bytes, std::uint32_t width,
133 if (!width || !height || pixels > maximumDecodedBytes / 4 || pixels > std::numeric_limits<std::size_t>::max() / 4 ||
134 columns * rows > std::numeric_limits<std::uint64_t>::max() / 16 || columns * rows * 16 != bytes.size())
136 Diagnostic::error(DiagnosticCode::InvalidArgument, "BC3 dimensions, byte count or decoded budget invalid",
209 for (unsigned i = 0; i < width; ++i, ++bit) code = (code << 1) | ((source[bit / 8] >> (7 - bit % 8)) & 1);
251Result<TiffPixels> decodeTiffRgba8(std::span<const std::uint8_t> bytes, std::uint64_t maximumDecodedBytes) {
253 if (bytes.size() < 8 || !((bytes[0] == 'I' && bytes[1] == 'I') || (bytes[0] == 'M' && bytes[1] == 'M')))
258 if (ifd < 8 || count > 4096 || std::uint64_t(ifd) + 2 + 12ull * count + 4 > bytes.size()) throw Invalid{};
261 const auto at = ifd + 2 + i * 12, id = r.read(at, 2), type = r.read(at + 2, 2), n = r.read(at + 4, 4);
281 for (unsigned i = 0; i < t.count; ++i) result.push_back(r.read(t.offset + std::size_t(i) * step, step));
289 const auto w = scalar(256, 0), h = scalar(257, 0), channels = scalar(277, 1), compression = scalar(259, 1);
290 const auto rows = scalar(278, UINT32_MAX), orientation = scalar(274, 1), predictor = scalar(317, 1);
291 if (!w || !h || !rows || maximumDecodedBytes < 24 || std::uint64_t(w) * h > (maximumDecodedBytes - 24) / 4)
293 if (scalar(262, 0) != 2 || scalar(284, 1) != 1 || (channels != 3 && channels != 4) || orientation < 1 ||
302 if (channels == 4 && (extra.size() != 1 || (extra[0] != 0 && extra[0] != 2))) throw Unsupported{};
304 if (compression != 1 && compression != 5 && compression != 8 && compression != 32946) throw Unsupported{};
306 if (offsets.size() != (std::uint64_t(h) + rows - 1) / rows || sizes.size() != offsets.size()) throw Invalid{};
353 "unsupported TIFF layout; requires unsigned 8/16-bit RGB(A) strips with raw, LZW or Deflate compression",
357 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:21
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Definition SourceBc3.h:8
Result< std::vector< std::uint8_t > > encodeSourcePng(std::uint32_t width, std::uint32_t height, std::span< const std::uint8_t > pixels, std::uint64_t maximumBytes)
Encode top-down RGBA8 source pixels without transfer conversion.
Definition SourcePng.cpp:14
Result< TgaPixels > decodeTgaRgba8(std::span< const std::uint8_t > b, std::uint64_t budget)
Decode true-color 24/32-bit raw or RLE TGA with bounded allocation.
Definition SourcePng.cpp:62
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 SourcePng.cpp:251
EVENGINE_API_FOUNDATION Result< std::vector< std::uint8_t > > decodeBc3Rgba8(std::span< const std::uint8_t > bytes, std::uint32_t width, std::uint32_t height, std::uint64_t maximumDecodedBytes)
Decode one BC3/DXT5 mip level into tightly packed RGBA8 in source row order.
Definition SourcePng.cpp:128
constexpr HexDirection next(HexDirection d) noexcept
The next direction clockwise (NW wraps to NE).
Definition HexMetrics.h:76
@ InvalidArgument
@ Unsupported
@ ParseError
Owning top-down RGBA8 pixels decoded from a TGA source.
Definition SourceTga.h:10
Owning top-down RGB(A) TIFF pixels; unspecified fourth samples remain alpha data.
Definition SourceTiff.h:10