mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-06 06:58:15 +00:00
Don't save transparent information on full-opaque .png files (fix #1572)
This commit is contained in:
parent
af3cc1d3c0
commit
33507fd097
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user