Fix wrong detection of alpha for grayscale images, after recent changes

Differential Revision: https://developer.blender.org/D14286
This commit is contained in:
Ethan-Hall 2022-03-09 14:53:01 +01:00 committed by Brecht Van Lommel
parent 6be665926c
commit ef3d76fbaa
2 changed files with 5 additions and 8 deletions

View File

@ -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);

View File

@ -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;
}