// 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.
Status EncodeHeader(const JxlBasicInfo& info, char* header, int* chars_written) { if (info.alpha_bits > 0) { return JXL_FAILURE("PGX: can't store alpha");
} if (info.num_color_channels != 1) { return JXL_FAILURE("PGX: must be grayscale");
} // TODO(lode): verify other bit depths: for other bit depths such as 1 or 4 // bits, have a test case to verify it works correctly. For bits > 16, we may // need to change the way external_image works. if (info.bits_per_sample != 8 && info.bits_per_sample != 16) { return JXL_FAILURE("PGX: bits other than 8 or 16 not yet supported");
}
// Use ML (Big Endian), LM may not be well supported by all decoders.
*chars_written = snprintf(header, kMaxHeaderSize, "PG ML + %u %u %u\n",
info.bits_per_sample, info.xsize, info.ysize);
JXL_RETURN_IF_ERROR(static_cast<unsignedint>(*chars_written) <
kMaxHeaderSize); returntrue;
}
Status EncodeImagePGX(const PackedFrame& frame, const JxlBasicInfo& info,
std::vector<uint8_t>* bytes) { char header[kMaxHeaderSize]; int header_size = 0;
JXL_RETURN_IF_ERROR(EncodeHeader(info, header, &header_size));
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.