Skip to content

Commit 19e6bc6

Browse files
aaronfrankefire
andcommitted
Explicitly handle Image AlphaMode enum instead of treating as bool
Co-authored-by: K. S. Ernest (iFire) Lee <[email protected]>
1 parent be3ecae commit 19e6bc6

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

drivers/png/png_driver_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Error image_to_png(const Ref<Image> &p_image, Vector<uint8_t> &p_buffer) {
152152
png_img.format = PNG_FORMAT_RGBA;
153153
break;
154154
default:
155-
if (source_image->detect_alpha()) {
155+
if (source_image->detect_alpha() != Image::ALPHA_NONE) {
156156
source_image->convert(Image::FORMAT_RGBA8);
157157
png_img.format = PNG_FORMAT_RGBA;
158158
} else {

editor/import/resource_importer_layered_texture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ Error ResourceImporterLayeredTexture::import(ResourceUID::ID p_source_id, const
349349
//if using video ram, optimize
350350
if (channel_pack == 0) {
351351
//remove alpha if not needed, so compression is more efficient
352-
if (image->get_format() == Image::FORMAT_RGBA8 && !image->detect_alpha()) {
352+
if (image->get_format() == Image::FORMAT_RGBA8 && image->detect_alpha() == Image::ALPHA_NONE) {
353353
image->convert(Image::FORMAT_RGB8);
354354
}
355355
} else if (image->get_format() < Image::FORMAT_RGBA8) {

modules/webp/webp_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Vector<uint8_t> _webp_packer(const Ref<Image> &p_image, float p_quality, bool p_
6060
Error error = img->decompress();
6161
ERR_FAIL_COND_V_MSG(error != OK, Vector<uint8_t>(), "Couldn't decompress image.");
6262
}
63-
if (img->detect_alpha()) {
63+
if (img->detect_alpha() != Image::ALPHA_NONE) {
6464
img->convert(Image::FORMAT_RGBA8);
6565
} else {
6666
img->convert(Image::FORMAT_RGB8);

0 commit comments

Comments
 (0)