@@ -253,7 +253,7 @@ static void flush_stream(png_structp out_ptr) {
253253 reinterpret_cast <Filesystem_Stream::OutputStream*>(png_get_io_ptr (out_ptr))->flush ();
254254}
255255
256- bool ImagePNG::Write (std::ostream& os, uint32_t width, uint32_t height, uint32_t * data) {
256+ bool ImagePNG::Write (std::ostream& os, uint32_t width, uint32_t height, uint32_t * data, bool transparent ) {
257257 png_structp write = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL , NULL , NULL );
258258 if (!write) {
259259 Output::Warning (" Bitmap::WritePNG: error in png_create_write" );
@@ -282,7 +282,7 @@ bool ImagePNG::Write(std::ostream& os, uint32_t width, uint32_t height, uint32_t
282282 png_set_write_fn (write, &os, &write_data, &flush_stream);
283283
284284 png_set_IHDR (write, info, width, height, 8 ,
285- PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
285+ transparent ? PNG_COLOR_TYPE_RGBA : PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
286286 PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
287287 png_write_info (write, info);
288288 png_write_image (write, ptrs);
0 commit comments