30 #define PNG_CHUNK_EXTRA 12
37 crc = crc32(crc, (
uint8_t *)&tag,
sizeof(tag));
50 const size_t line_size = thumb->
width * 4;
52 size_t final_size = thumb->
height * (line_size + 1);
53 filtered.reserve(final_size);
54 for (
int i = 0; i < thumb->
height; i++) {
55 filtered.append_unchecked(0x00);
64 unsigned long uncompressed_size =
data.size();
65 uLongf compressed_size = compressBound(uncompressed_size);
69 int return_value = compress2((
uchar *)compressed.
data(),
74 if (return_value != Z_OK) {
78 compressed.
resize(compressed_size);
93 if (image_data_opt == std::nullopt) {
96 image_data = *image_data_opt;
102 const size_t ihdr_data_final_size = 4 + 4 + 5;
103 ihdr_data.
reserve(ihdr_data_final_size);
106 ihdr_data.extend_unchecked({
113 BLI_assert((
size_t)ihdr_data.size() == ihdr_data_final_size);
119 const size_t png_buf_final_size = (
129 png_buf.
reserve(png_buf_final_size);
132 png_buf.extend_unchecked({0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A});
138 BLI_assert((
size_t)png_buf.size() == png_buf_final_size);
BLI_INLINE void BLI_endian_switch_int32(int *val) ATTR_NONNULL(1)
#define MAKE_ID(a, b, c, d)
static std::optional< blender::Vector< uint8_t > > zlib_compress(const blender::Vector< uint8_t > &data)
std::optional< blender::Vector< uint8_t > > blendthumb_create_png_data_from_thumb(const Thumbnail *thumb)
static void png_extend_native_int32(blender::Vector< uint8_t > &output, int32_t data)
static blender::Vector< uint8_t > filtered_rows_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 reserve(const int64_t min_capacity)
ccl_global KernelShaderEvalInput ccl_global float * output
blender::Array< uint8_t > data