Browse Source

Fix gray+alpha alpha extract.

Jeroen van Rijn 4 years ago
parent
commit
afb6ebd21e
1 changed files with 4 additions and 4 deletions
  1. 4 4
      core/image/common.odin

+ 4 - 4
core/image/common.odin

@@ -150,15 +150,15 @@ return_single_channel :: proc(img: ^Image, channel: Channel) -> (res: ^Image, ok
 
 	idx := int(channel);
 
-	if idx > img.channels {
-		return {}, false;
-	}
-
 	if img.channels == 2 && idx == 4 {
 		// Alpha requested, which in a two channel image is index 2: G.
 		idx = 2;
 	}
 
+	if idx > img.channels {
+		return {}, false;
+	}
+
 	switch(img.depth) {
 		case 8:
 			buffer_size := compute_buffer_size(img.width, img.height, 1, 8);