diff --git a/src/app/file/png_format.cpp b/src/app/file/png_format.cpp index 797a597ee..f69200fdd 100644 --- a/src/app/file/png_format.cpp +++ b/src/app/file/png_format.cpp @@ -446,6 +446,7 @@ bool PngFormat::onSave(FileOp* fop) mask_entry = fop->document()->sprite()->transparentColor(); } + bool all_opaque = true; int num_trans = pal_size; png_bytep trans = (png_bytep)png_malloc(png_ptr, num_trans); @@ -453,9 +454,13 @@ bool PngFormat::onSave(FileOp* fop) int alpha = 255; fop->sequenceGetAlpha(c, &alpha); trans[c] = (c == mask_entry ? 0: alpha); + if (alpha < 255) + all_opaque = false; } - png_set_tRNS(png_ptr, info_ptr, trans, num_trans, NULL); + if (!all_opaque || mask_entry >= 0) + png_set_tRNS(png_ptr, info_ptr, trans, num_trans, nullptr); + png_free(png_ptr, trans); }