diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-01-02 23:52:51 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-03-08 21:52:21 +0100 |
| commit | 75100e5e76b88c954e75b576be952a4fc53fa45f (patch) | |
| tree | 90c2e135d0cb79f97169e8c7c1a64e2a933ed449 | |
| parent | 251c4cadd2708224bcf1774bf7114d44f9ff6c89 (diff) | |
Allow image_as_png() to cope with RGB as well as RGBA without conversion.
| -rw-r--r-- | src/lib/image_png.cc | 8 |
1 files 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<const Image> 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<const Image> 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_byte **>(png_malloc(png_ptr, image->size().height * sizeof(png_byte *))); auto const data = image->data()[0]; |
