removed threshold
This commit is contained in:
parent
d7c597e513
commit
5dc41ff29f
|
|
@ -33,19 +33,19 @@ int main(void)
|
||||||
Image fudesumiImage = LoadImage("resources/fudesumi.png");
|
Image fudesumiImage = LoadImage("resources/fudesumi.png");
|
||||||
Texture2D fudesumiTexture = LoadTextureFromImage(fudesumiImage);
|
Texture2D fudesumiTexture = LoadTextureFromImage(fudesumiImage);
|
||||||
|
|
||||||
Image imageRed = ImageFromChannel(fudesumiImage, 0, 0.0f);
|
Image imageRed = ImageFromChannel(fudesumiImage, 0);
|
||||||
Texture2D textureRed = LoadTextureFromImage(imageRed);
|
Texture2D textureRed = LoadTextureFromImage(imageRed);
|
||||||
UnloadImage(imageRed);
|
UnloadImage(imageRed);
|
||||||
|
|
||||||
Image imageGreen = ImageFromChannel(fudesumiImage, 1, 0.0f);
|
Image imageGreen = ImageFromChannel(fudesumiImage, 1);
|
||||||
Texture2D textureGreen = LoadTextureFromImage(imageGreen);
|
Texture2D textureGreen = LoadTextureFromImage(imageGreen);
|
||||||
UnloadImage(imageGreen);
|
UnloadImage(imageGreen);
|
||||||
|
|
||||||
Image imageBlue = ImageFromChannel(fudesumiImage, 2, 0.0f);
|
Image imageBlue = ImageFromChannel(fudesumiImage, 2);
|
||||||
Texture2D textureBlue = LoadTextureFromImage(imageBlue);
|
Texture2D textureBlue = LoadTextureFromImage(imageBlue);
|
||||||
UnloadImage(imageBlue);
|
UnloadImage(imageBlue);
|
||||||
|
|
||||||
Image imageAlpha = ImageFromChannel(fudesumiImage, 3, 0.0f);
|
Image imageAlpha = ImageFromChannel(fudesumiImage, 3);
|
||||||
Texture2D textureAlpha = LoadTextureFromImage(imageAlpha);
|
Texture2D textureAlpha = LoadTextureFromImage(imageAlpha);
|
||||||
UnloadImage(imageAlpha);
|
UnloadImage(imageAlpha);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 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 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 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 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 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
|
RLAPI void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle
|
||||||
|
|
|
||||||
|
|
@ -1630,7 +1630,8 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
|
||||||
return imText;
|
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 };
|
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))
|
if ((image.data == NULL) || (image.width == 0) || (image.height == 0))
|
||||||
return result;
|
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
|
// Check selected channel
|
||||||
if (selectedChannel < 0)
|
if (selectedChannel < 0)
|
||||||
{
|
{
|
||||||
|
|
@ -1851,14 +1840,11 @@ Image ImageFromChannel(Image image, int selectedChannel, float threshold)
|
||||||
// verify threshold
|
// verify threshold
|
||||||
unsigned char resultValue = 0;
|
unsigned char resultValue = 0;
|
||||||
unsigned char resultAlpha = 0;
|
unsigned char resultAlpha = 0;
|
||||||
if (imageValue >= threshold)
|
|
||||||
{
|
|
||||||
resultValue = imageValue * 255;
|
resultValue = imageValue * 255;
|
||||||
if (imageAlpha)
|
if (imageAlpha)
|
||||||
{
|
{
|
||||||
resultAlpha = 255;
|
resultAlpha = 255;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pixels[i] = resultValue;
|
pixels[i] = resultValue;
|
||||||
pixels[i + 1] = resultAlpha;
|
pixels[i + 1] = resultAlpha;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user