Fixing build on gcc/clang

This commit is contained in:
Vojtech Bubnik 2021-02-22 19:43:04 +01:00
parent 03dee86071
commit 7b52dc2324

View File

@ -149,13 +149,15 @@ static bool write_rgb_or_gray_to_file(const char *file_name_utf8, size_t width,
// Initialize rows of PNG. // Initialize rows of PNG.
row_pointers = reinterpret_cast<png_byte**>(::png_malloc(png_ptr, height * sizeof(png_byte*))); row_pointers = reinterpret_cast<png_byte**>(::png_malloc(png_ptr, height * sizeof(png_byte*)));
int line_width = width; {
if (png_color_type == PNG_COLOR_TYPE_RGB) int line_width = width;
line_width *= 3; if (png_color_type == PNG_COLOR_TYPE_RGB)
for (size_t y = 0; y < height; ++ y) { line_width *= 3;
auto row = reinterpret_cast<png_byte*>(::png_malloc(png_ptr, line_width)); for (size_t y = 0; y < height; ++ y) {
row_pointers[y] = row; auto row = reinterpret_cast<png_byte*>(::png_malloc(png_ptr, line_width));
memcpy(row, data + line_width * y, line_width); row_pointers[y] = row;
memcpy(row, data + line_width * y, line_width);
}
} }
// Write the image data to "fp". // Write the image data to "fp".