From 75100e5e76b88c954e75b576be952a4fc53fa45f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 2 Jan 2025 23:52:51 +0100 Subject: Allow image_as_png() to cope with RGB as well as RGBA without conversion. --- src/lib/image_png.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/image_png.cc b/src/lib/image_png.cc index e56b68d9a..1ff232286 100644 --- a/src/lib/image_png.cc +++ b/src/lib/image_png.cc @@ -85,14 +85,14 @@ png_error_fn (png_structp, char const * message) dcp::ArrayData image_as_png (shared_ptr image) { - png_byte color_type; + png_byte colour_type = 0; switch (image->pixel_format()) { case AV_PIX_FMT_RGBA: - color_type = PNG_COLOR_TYPE_RGBA; + colour_type = PNG_COLOR_TYPE_RGBA; break; case AV_PIX_FMT_RGB24: - color_type = PNG_COLOR_TYPE_RGB; + colour_type = PNG_COLOR_TYPE_RGB; break; default: return image_as_png(image->convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_RGBA, Image::Alignment::PADDED, false)); @@ -117,7 +117,7 @@ image_as_png (shared_ptr image) int const width = image->size().width; int const height = image->size().height; - png_set_IHDR(png_ptr, info_ptr, width, height, 8, color_type, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + png_set_IHDR(png_ptr, info_ptr, width, height, 8, colour_type, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); auto row_pointers = reinterpret_cast(png_malloc(png_ptr, image->size().height * sizeof(png_byte *))); auto const data = image->data()[0]; -- cgit v1.2.3