From ef3d76fbaa37110fd857f3aabff815600e43915a Mon Sep 17 00:00:00 2001 From: Ethan-Hall Date: Wed, 9 Mar 2022 14:53:01 +0100 Subject: Fix wrong detection of alpha for grayscale images, after recent changes Differential Revision: https://developer.blender.org/D14286 --- source/blender/blenkernel/BKE_image.h | 2 +- source/blender/blenkernel/intern/image.c | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index b3001ecc880..a5a2d57f9d3 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -371,7 +371,7 @@ void BKE_image_merge(struct Main *bmain, struct Image *dest, struct Image *sourc bool BKE_image_scale(struct Image *image, int width, int height); /** - * Check if texture has alpha (depth=32). + * Check if texture has alpha (planes == 32 || planes == 16). */ bool BKE_image_has_alpha(struct Image *image); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 8a212ed0d7d..e01f8cb76c8 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -5853,17 +5853,14 @@ void BKE_image_user_file_path_ex(ImageUser *iuser, Image *ima, char *filepath, b BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&ima->id)); } -bool BKE_image_has_alpha(struct Image *image) +bool BKE_image_has_alpha(Image *image) { - ImBuf *ibuf; void *lock; - int planes; - - ibuf = BKE_image_acquire_ibuf(image, NULL, &lock); - planes = (ibuf ? ibuf->planes : 0); + ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, &lock); + const int planes = (ibuf ? ibuf->planes : 0); BKE_image_release_ibuf(image, ibuf, lock); - if (planes == 32) { + if (planes == 32 || planes == 16) { return true; } -- cgit v1.2.3