31#define PNG_CHUNK_EXTRA 12
38 crc = crc32(crc, (
uint8_t *)&tag,
sizeof(tag));
39 crc = crc32(crc, (
uint8_t *)data.data(), data.size());
43 output.extend_unchecked(data);
51 const size_t line_size = thumb->
width * 4;
53 size_t final_size = thumb->
height * (line_size + 1);
55 for (
int i = 0; i < thumb->
height; i++) {
66 uLongf compressed_size = compressBound(uncompressed_size);
70 int return_value = compress2((
uchar *)compressed.
data(),
75 if (return_value != Z_OK) {
79 compressed.
resize(compressed_size);
94 if (image_data_opt == std::nullopt) {
97 image_data = *image_data_opt;
103 const size_t ihdr_data_final_size = 4 + 4 + 5;
104 ihdr_data.
reserve(ihdr_data_final_size);
120 const size_t png_buf_final_size = (
130 png_buf.
reserve(png_buf_final_size);
BLI_INLINE void BLI_endian_switch_int32(int *val) ATTR_NONNULL(1)
#define MAKE_ID(a, b, c, d)
static blender::Vector< uint8_t > filtered_rows_from_thumb(const Thumbnail *thumb)
static std::optional< blender::Vector< uint8_t > > zlib_compress(const blender::Vector< uint8_t > &data)
static void png_extend_native_int32(blender::Vector< uint8_t > &output, int32_t data)
std::optional< blender::Vector< uint8_t > > blendthumb_create_png_data_from_thumb(const Thumbnail *thumb)
static void png_chunk_create(blender::Vector< uint8_t > &output, const uint32_t tag, const blender::Vector< uint8_t > &data)
void resize(const int64_t new_size)
void extend_unchecked(Span< T > array)
void append_unchecked(const T &value)
void reserve(const int64_t min_capacity)
blender::Array< uint8_t > data