// Copyright (c) the JPEG XL Project Authors. All rights reserved. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file.
// Class representing an interleaved image with a bunch of channels. class PackedImage { public: static StatusOr<PackedImage> Create(size_t xsize, size_t ysize, const JxlPixelFormat& format) {
PackedImage image(xsize, ysize, format, CalcStride(format, xsize)); if (!image.pixels()) { // TODO(szabadka): use specialized OOM error code return JXL_FAILURE("Failed to allocate memory for image");
} return image;
}
// The interleaved pixels as defined in the storage format. void* pixels() const { return pixels_.get(); }
uint8_t* pixels(size_t y, size_t x, size_t c) const { return (reinterpret_cast<uint8_t*>(pixels_.get()) + y * stride +
x * pixel_stride_ + c * bytes_per_channel_);
}
const uint8_t* const_pixels(size_t y, size_t x, size_t c) const { return (reinterpret_cast<const uint8_t*>(pixels_.get()) + y * stride +
x * pixel_stride_ + c * bytes_per_channel_);
}
// The image size in pixels.
size_t xsize;
size_t ysize;
// The number of bytes per row.
size_t stride;
// Pixel storage format and buffer size of the pixels_ pointer.
JxlPixelFormat format;
size_t pixels_size;
// Helper class representing a frame, as seen from the API. Animations will have // multiple frames, but a single frame can have a color/grayscale channel and // multiple extra channels. The order of the extra channels should be the same // as all other frames in the same image. class PackedFrame { public: explicit PackedFrame(PackedImage&& image) : color(std::move(image)) {}
// Color information of the decoded pixels. // `primary_color_representation` indicates whether `color_encoding` or `icc` // is the “authoritative” encoding of the colorspace, as opposed to a fallback // encoding. For example, if `color_encoding` is the primary one, as would // occur when decoding a jxl file with such a representation, then `enc/jxl` // will use it and ignore the ICC profile, whereas `enc/png` will include the // ICC profile for compatibility. // If `icc` is the primary representation, `enc/jxl` will preserve it when // compressing losslessly, but *may* encode it as a color_encoding when // compressing lossily. enum {
kColorEncodingIsPrimary,
kIccIsPrimary
} primary_color_representation = kColorEncodingIsPrimary;
JxlColorEncoding color_encoding = {};
std::vector<uint8_t> icc; // The icc profile of the original image.
std::vector<uint8_t> orig_icc;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.