diff --git a/examples/textures/textures_image_channel.c b/examples/textures/textures_image_channel.c index 46817f814..5ea9acce2 100644 --- a/examples/textures/textures_image_channel.c +++ b/examples/textures/textures_image_channel.c @@ -33,19 +33,19 @@ int main(void) Image fudesumiImage = LoadImage("resources/fudesumi.png"); Texture2D fudesumiTexture = LoadTextureFromImage(fudesumiImage); - Image imageRed = ImageFromChannel(fudesumiImage, 0, 0.0f); + Image imageRed = ImageFromChannel(fudesumiImage, 0); Texture2D textureRed = LoadTextureFromImage(imageRed); UnloadImage(imageRed); - Image imageGreen = ImageFromChannel(fudesumiImage, 1, 0.0f); + Image imageGreen = ImageFromChannel(fudesumiImage, 1); Texture2D textureGreen = LoadTextureFromImage(imageGreen); UnloadImage(imageGreen); - Image imageBlue = ImageFromChannel(fudesumiImage, 2, 0.0f); + Image imageBlue = ImageFromChannel(fudesumiImage, 2); Texture2D textureBlue = LoadTextureFromImage(imageBlue); UnloadImage(imageBlue); - Image imageAlpha = ImageFromChannel(fudesumiImage, 3, 0.0f); + Image imageAlpha = ImageFromChannel(fudesumiImage, 3); Texture2D textureAlpha = LoadTextureFromImage(imageAlpha); UnloadImage(imageAlpha); diff --git a/src/raylib.h b/src/raylib.h index 0ba56030a..c1c0a8f4c 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1334,7 +1334,7 @@ RLAPI Image ImageCopy(Image image); RLAPI Image ImageFromImage(Image image, Rectangle rec); // Create an image from another image piece RLAPI Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font) RLAPI Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font) -RLAPI Image ImageFromChannel(Image image, int selectedChannel, float threshold); // Create an image from a selected channel of another image (Gray Alpha or RGBA) +RLAPI Image ImageFromChannel(Image image, int selectedChannel); // Create an image from a selected channel of another image RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format RLAPI void ImageToPOT(Image *image, Color fill); // Convert image to POT (power-of-two) RLAPI void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle diff --git a/src/rtextures.c b/src/rtextures.c index f329833bc..b276b5ba9 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -1630,7 +1630,8 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co return imText; } -Image ImageFromChannel(Image image, int selectedChannel, float threshold) +// Create an image from a selected channel of another image +Image ImageFromChannel(Image image, int selectedChannel) { Image result = { 0 }; @@ -1638,18 +1639,6 @@ Image ImageFromChannel(Image image, int selectedChannel, float threshold) if ((image.data == NULL) || (image.width == 0) || (image.height == 0)) return result; - // Check thresholds limits - if (threshold < 0.0f) - { - TRACELOG(LOG_WARNING, "Threshold is from 0 to 1, changing to 0."); - threshold = 0.0f; - } - if (threshold > 1.0f) - { - TRACELOG(LOG_WARNING, "Threshold is from 0 to 1, changing to 1."); - threshold = 1.0f; - } - // Check selected channel if (selectedChannel < 0) { @@ -1851,13 +1840,10 @@ Image ImageFromChannel(Image image, int selectedChannel, float threshold) // verify threshold unsigned char resultValue = 0; unsigned char resultAlpha = 0; - if (imageValue >= threshold) + resultValue = imageValue * 255; + if (imageAlpha) { - resultValue = imageValue * 255; - if (imageAlpha) - { - resultAlpha = 255; - } + resultAlpha = 255; } pixels[i] = resultValue;