From 7640b0a64d8f3e4e0808439c0a593d67740d4515 Mon Sep 17 00:00:00 2001 From: Peteris Krumins Date: Tue, 20 Jul 2010 18:44:59 +0300 Subject: [PATCH] fixed a bug where i had forgotten to set correct color type for BUF_BGR --- png.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/png.cc b/png.cc index cad3ca9..a47108d 100644 --- a/png.cc +++ b/png.cc @@ -85,7 +85,11 @@ class PngEncoder { if (!png_ptr) return VException("png_create_info_struct failed."); - int color_type = (buf_type == BUF_RGB) ? PNG_COLOR_TYPE_RGB : PNG_COLOR_TYPE_RGB_ALPHA; + int color_type; + if (buf_type == BUF_RGB || buf_type == BUF_BGR) + color_type = PNG_COLOR_TYPE_RGB; + else + color_type = PNG_COLOR_TYPE_RGB_ALPHA; png_set_IHDR(png_ptr, info_ptr, width, height, 8, color_type, PNG_INTERLACE_NONE,