naming convention
This commit is contained in:
parent
0576b47320
commit
791f1c11da
|
|
@ -30,37 +30,37 @@ int main(void)
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [textures] example - extract channel from image");
|
InitWindow(screenWidth, screenHeight, "raylib [textures] example - extract channel from image");
|
||||||
|
|
||||||
Image fudesumi_image = LoadImage("resources/fudesumi.png");
|
Image fudesumiImage = LoadImage("resources/fudesumi.png");
|
||||||
Texture2D fudesumi_texture = LoadTextureFromImage(fudesumi_image);
|
Texture2D fudesumiTexture = LoadTextureFromImage(fudesumiImage);
|
||||||
|
|
||||||
Image image_red = ImageFromChannel(fudesumi_image, 0, 0.0f);
|
Image imageRed = ImageFromChannel(fudesumiImage, 0, 0.0f);
|
||||||
Texture2D texture_red = LoadTextureFromImage(image_red);
|
Texture2D textureRed = LoadTextureFromImage(imageRed);
|
||||||
UnloadImage(image_red);
|
UnloadImage(imageRed);
|
||||||
|
|
||||||
Image image_green = ImageFromChannel(fudesumi_image, 1, 0.0f);
|
Image imageGreen = ImageFromChannel(fudesumiImage, 1, 0.0f);
|
||||||
Texture2D texture_green = LoadTextureFromImage(image_green);
|
Texture2D textureGreen = LoadTextureFromImage(imageGreen);
|
||||||
UnloadImage(image_green);
|
UnloadImage(imageGreen);
|
||||||
|
|
||||||
Image image_blue = ImageFromChannel(fudesumi_image, 2, 0.0f);
|
Image imageBlue = ImageFromChannel(fudesumiImage, 2, 0.0f);
|
||||||
Texture2D texture_blue = LoadTextureFromImage(image_blue);
|
Texture2D textureBlue = LoadTextureFromImage(imageBlue);
|
||||||
UnloadImage(image_blue);
|
UnloadImage(imageBlue);
|
||||||
|
|
||||||
Image image_alpha = ImageFromChannel(fudesumi_image, 3, 0.0f);
|
Image imageAlpha = ImageFromChannel(fudesumiImage, 3, 0.0f);
|
||||||
Texture2D texture_alpha = LoadTextureFromImage(image_alpha);
|
Texture2D textureAlpha = LoadTextureFromImage(imageAlpha);
|
||||||
UnloadImage(image_alpha);
|
UnloadImage(imageAlpha);
|
||||||
|
|
||||||
|
|
||||||
Image background_image = GenImageChecked(screenWidth, screenHeight, screenWidth/20, screenHeight/20, ORANGE, YELLOW);
|
Image backgroundImage = GenImageChecked(screenWidth, screenHeight, screenWidth/20, screenHeight/20, ORANGE, YELLOW);
|
||||||
Texture2D background_texture = LoadTextureFromImage(background_image);
|
Texture2D backgroundTexture = LoadTextureFromImage(backgroundImage);
|
||||||
UnloadImage(background_image);
|
UnloadImage(backgroundImage);
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
|
||||||
Rectangle fudesumi_rec = {0, 0, fudesumi_image.width, fudesumi_image.height};
|
Rectangle fudesumiRec = {0, 0, fudesumiImage.width, fudesumiImage.height};
|
||||||
Rectangle red_pos = { 410, 50, fudesumi_image.width / 2, fudesumi_image.height / 2 };
|
Rectangle redPos = { 410, 50, fudesumiImage.width / 2, fudesumiImage.height / 2 };
|
||||||
Rectangle green_pos = { 600, 50, fudesumi_image.width / 2, fudesumi_image.height / 2 };
|
Rectangle greenPos = { 600, 50, fudesumiImage.width / 2, fudesumiImage.height / 2 };
|
||||||
Rectangle blue_pos = { 410, 310, fudesumi_image.width / 2, fudesumi_image.height / 2 };
|
Rectangle bluePos = { 410, 310, fudesumiImage.width / 2, fudesumiImage.height / 2 };
|
||||||
Rectangle alpha_pos = { 600, 310, fudesumi_image.width / 2, fudesumi_image.height / 2 };
|
Rectangle alphaPos = { 600, 310, fudesumiImage.width / 2, fudesumiImage.height / 2 };
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -71,13 +71,13 @@ int main(void)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
DrawTexture(background_texture, 0, 0, WHITE);
|
DrawTexture(backgroundTexture, 0, 0, WHITE);
|
||||||
DrawTexture(fudesumi_texture, 50, 50, WHITE);
|
DrawTexture(fudesumiTexture, 50, 50, WHITE);
|
||||||
|
|
||||||
DrawTexturePro(texture_red, fudesumi_rec, red_pos, (Vector2) {0, 0}, 0, RED);
|
DrawTexturePro(textureRed, fudesumiRec, redPos, (Vector2) {0, 0}, 0, RED);
|
||||||
DrawTexturePro(texture_green, fudesumi_rec, green_pos, (Vector2) {0, 0}, 0, GREEN);
|
DrawTexturePro(textureGreen, fudesumiRec, greenPos, (Vector2) {0, 0}, 0, GREEN);
|
||||||
DrawTexturePro(texture_blue, fudesumi_rec, blue_pos, (Vector2) {0, 0}, 0, BLUE);
|
DrawTexturePro(textureBlue, fudesumiRec, bluePos, (Vector2) {0, 0}, 0, BLUE);
|
||||||
DrawTexturePro(texture_alpha, fudesumi_rec, alpha_pos, (Vector2) {0, 0}, 0, WHITE);
|
DrawTexturePro(textureAlpha, fudesumiRec, alphaPos, (Vector2) {0, 0}, 0, WHITE);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
@ -85,13 +85,13 @@ int main(void)
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
UnloadTexture(background_texture);
|
UnloadTexture(backgroundTexture);
|
||||||
UnloadImage(fudesumi_image);
|
UnloadImage(fudesumiImage);
|
||||||
UnloadTexture(fudesumi_texture);
|
UnloadTexture(fudesumiTexture);
|
||||||
UnloadTexture(texture_red);
|
UnloadTexture(textureRed);
|
||||||
UnloadTexture(texture_green);
|
UnloadTexture(textureGreen);
|
||||||
UnloadTexture(texture_blue);
|
UnloadTexture(textureBlue);
|
||||||
UnloadTexture(texture_alpha);
|
UnloadTexture(textureAlpha);
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 selected_channel, float threshold); // Create an image from a selected channel of another image (Gray Alpha or RGBA)
|
RLAPI Image ImageFromChannel(Image image, int selectedChannel, float threshold); // Create an image from a selected channel of another image (Gray Alpha or RGBA)
|
||||||
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
|
||||||
|
|
|
||||||
133
src/rtextures.c
133
src/rtextures.c
|
|
@ -1630,7 +1630,7 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
|
||||||
return imText;
|
return imText;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image ImageFromChannel(Image image, int selected_channel, float threshold)
|
Image ImageFromChannel(Image image, int selectedChannel, float threshold)
|
||||||
{
|
{
|
||||||
Image result = { 0 };
|
Image result = { 0 };
|
||||||
|
|
||||||
|
|
@ -1651,23 +1651,28 @@ Image ImageFromChannel(Image image, int selected_channel, float threshold)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check selected channel
|
// Check selected channel
|
||||||
|
if (selectedChannel < 0)
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_WARNING, "Channel cannot be negative. Setting channel to 0.");
|
||||||
|
selectedChannel = 0;
|
||||||
|
}
|
||||||
if (image.format == PIXELFORMAT_UNCOMPRESSED_GRAYSCALE
|
if (image.format == PIXELFORMAT_UNCOMPRESSED_GRAYSCALE
|
||||||
|| image.format == PIXELFORMAT_UNCOMPRESSED_R32
|
|| image.format == PIXELFORMAT_UNCOMPRESSED_R32
|
||||||
|| image.format == PIXELFORMAT_UNCOMPRESSED_R16
|
|| image.format == PIXELFORMAT_UNCOMPRESSED_R16
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (selected_channel > 0)
|
if (selectedChannel > 0)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "This image has only 1 channel. Setting channel to it.");
|
TRACELOG(LOG_WARNING, "This image has only 1 channel. Setting channel to it.");
|
||||||
selected_channel = 0;
|
selectedChannel = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (image.format == PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA)
|
else if (image.format == PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA)
|
||||||
{
|
{
|
||||||
if (selected_channel > 1)
|
if (selectedChannel > 1)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "This image has only 2 channels. Setting channel to alpha.");
|
TRACELOG(LOG_WARNING, "This image has only 2 channels. Setting channel to alpha.");
|
||||||
selected_channel = 1;
|
selectedChannel = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (image.format == PIXELFORMAT_UNCOMPRESSED_R5G6B5
|
else if (image.format == PIXELFORMAT_UNCOMPRESSED_R5G6B5
|
||||||
|
|
@ -1676,18 +1681,18 @@ Image ImageFromChannel(Image image, int selected_channel, float threshold)
|
||||||
|| image.format == PIXELFORMAT_UNCOMPRESSED_R16G16B16
|
|| image.format == PIXELFORMAT_UNCOMPRESSED_R16G16B16
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (selected_channel > 2)
|
if (selectedChannel > 2)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "This image has only 3 channels. Setting channel to red.");
|
TRACELOG(LOG_WARNING, "This image has only 3 channels. Setting channel to red.");
|
||||||
selected_channel = 0;
|
selectedChannel = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// formats rgba
|
// formats rgba
|
||||||
if (selected_channel > 3 || selected_channel < 0)
|
if (selectedChannel > 3)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "ImageFromChannel supports channels 0 to 3 (rgba). Setting channel to alpha.");
|
TRACELOG(LOG_WARNING, "ImageFromChannel supports channels 0 to 3 (rgba). Setting channel to alpha.");
|
||||||
selected_channel = 3;
|
selectedChannel = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.format = PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA;
|
result.format = PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA;
|
||||||
|
|
@ -1702,20 +1707,20 @@ Image ImageFromChannel(Image image, int selected_channel, float threshold)
|
||||||
{
|
{
|
||||||
for (int i = 0, k = 0; i < image.width*2*image.height; i+=2)
|
for (int i = 0, k = 0; i < image.width*2*image.height; i+=2)
|
||||||
{
|
{
|
||||||
float image_value = -1;
|
float imageValue = -1;
|
||||||
float image_alpha = 0;
|
float imageAlpha = 0;
|
||||||
switch (image.format)
|
switch (image.format)
|
||||||
{
|
{
|
||||||
case PIXELFORMAT_UNCOMPRESSED_GRAYSCALE:
|
case PIXELFORMAT_UNCOMPRESSED_GRAYSCALE:
|
||||||
{
|
{
|
||||||
image_value = (float)((unsigned char *)image.data)[i + selected_channel]/255.0f;
|
imageValue = (float)((unsigned char *)image.data)[i + selectedChannel]/255.0f;
|
||||||
image_alpha = 1;
|
imageAlpha = 1;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA:
|
case PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA:
|
||||||
{
|
{
|
||||||
image_value = (float)((unsigned char *)image.data)[k + selected_channel]/255.0f;
|
imageValue = (float)((unsigned char *)image.data)[k + selectedChannel]/255.0f;
|
||||||
image_alpha = (float)((unsigned char *)image.data)[k + 1]/255.0f;
|
imageAlpha = (float)((unsigned char *)image.data)[k + 1]/255.0f;
|
||||||
|
|
||||||
k += 2;
|
k += 2;
|
||||||
} break;
|
} break;
|
||||||
|
|
@ -1723,120 +1728,120 @@ Image ImageFromChannel(Image image, int selected_channel, float threshold)
|
||||||
{
|
{
|
||||||
unsigned short pixel = ((unsigned short *)image.data)[i];
|
unsigned short pixel = ((unsigned short *)image.data)[i];
|
||||||
|
|
||||||
if (selected_channel == 0)
|
if (selectedChannel == 0)
|
||||||
{
|
{
|
||||||
image_value = (float)((pixel & 0b1111100000000000) >> 11)*(1.0f/31);
|
imageValue = (float)((pixel & 0b1111100000000000) >> 11)*(1.0f/31);
|
||||||
}
|
}
|
||||||
else if (selected_channel == 1)
|
else if (selectedChannel == 1)
|
||||||
{
|
{
|
||||||
image_value = (float)((pixel & 0b0000011111000000) >> 6)*(1.0f/31);
|
imageValue = (float)((pixel & 0b0000011111000000) >> 6)*(1.0f/31);
|
||||||
}
|
}
|
||||||
else if (selected_channel == 2)
|
else if (selectedChannel == 2)
|
||||||
{
|
{
|
||||||
image_value = (float)((pixel & 0b0000000000111110) >> 1)*(1.0f/31);
|
imageValue = (float)((pixel & 0b0000000000111110) >> 1)*(1.0f/31);
|
||||||
}
|
}
|
||||||
else if (selected_channel == 3)
|
else if (selectedChannel == 3)
|
||||||
{
|
{
|
||||||
image_value = ((pixel & 0b0000000000000001) == 0)? 0.0f : 1.0f;
|
imageValue = ((pixel & 0b0000000000000001) == 0)? 0.0f : 1.0f;
|
||||||
}
|
}
|
||||||
image_alpha = ((pixel & 0b0000000000000001) == 0)? 0.0f : 1.0f;
|
imageAlpha = ((pixel & 0b0000000000000001) == 0)? 0.0f : 1.0f;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R5G6B5:
|
case PIXELFORMAT_UNCOMPRESSED_R5G6B5:
|
||||||
{
|
{
|
||||||
unsigned short pixel = ((unsigned short *)image.data)[i];
|
unsigned short pixel = ((unsigned short *)image.data)[i];
|
||||||
|
|
||||||
if (selected_channel == 0)
|
if (selectedChannel == 0)
|
||||||
{
|
{
|
||||||
image_value = (float)((pixel & 0b1111100000000000) >> 11)*(1.0f/31);
|
imageValue = (float)((pixel & 0b1111100000000000) >> 11)*(1.0f/31);
|
||||||
}
|
}
|
||||||
else if (selected_channel == 1)
|
else if (selectedChannel == 1)
|
||||||
{
|
{
|
||||||
image_value = (float)((pixel & 0b0000011111100000) >> 5)*(1.0f/63);
|
imageValue = (float)((pixel & 0b0000011111100000) >> 5)*(1.0f/63);
|
||||||
}
|
}
|
||||||
else if (selected_channel == 2)
|
else if (selectedChannel == 2)
|
||||||
{
|
{
|
||||||
image_value = (float)(pixel & 0b0000000000011111)*(1.0f/31);
|
imageValue = (float)(pixel & 0b0000000000011111)*(1.0f/31);
|
||||||
}
|
}
|
||||||
image_alpha = 1;
|
imageAlpha = 1;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R4G4B4A4:
|
case PIXELFORMAT_UNCOMPRESSED_R4G4B4A4:
|
||||||
{
|
{
|
||||||
unsigned short pixel = ((unsigned short *)image.data)[i];
|
unsigned short pixel = ((unsigned short *)image.data)[i];
|
||||||
|
|
||||||
if (selected_channel == 0)
|
if (selectedChannel == 0)
|
||||||
{
|
{
|
||||||
image_value = (float)((pixel & 0b1111000000000000) >> 12)*(1.0f/15);
|
imageValue = (float)((pixel & 0b1111000000000000) >> 12)*(1.0f/15);
|
||||||
}
|
}
|
||||||
else if (selected_channel == 1)
|
else if (selectedChannel == 1)
|
||||||
{
|
{
|
||||||
image_value = (float)((pixel & 0b0000111100000000) >> 8)*(1.0f/15);
|
imageValue = (float)((pixel & 0b0000111100000000) >> 8)*(1.0f/15);
|
||||||
}
|
}
|
||||||
else if (selected_channel == 2)
|
else if (selectedChannel == 2)
|
||||||
{
|
{
|
||||||
image_value = (float)((pixel & 0b0000000011110000) >> 4)*(1.0f/15);
|
imageValue = (float)((pixel & 0b0000000011110000) >> 4)*(1.0f/15);
|
||||||
}
|
}
|
||||||
else if (selected_channel == 3)
|
else if (selectedChannel == 3)
|
||||||
{
|
{
|
||||||
image_value = (float)(pixel & 0b0000000000001111)*(1.0f/15);
|
imageValue = (float)(pixel & 0b0000000000001111)*(1.0f/15);
|
||||||
}
|
}
|
||||||
image_alpha = (float)(pixel & 0b0000000000001111)*(1.0f/15);
|
imageAlpha = (float)(pixel & 0b0000000000001111)*(1.0f/15);
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R8G8B8A8:
|
case PIXELFORMAT_UNCOMPRESSED_R8G8B8A8:
|
||||||
{
|
{
|
||||||
image_value = (float)((unsigned char *)image.data)[k + selected_channel]/255.0f;
|
imageValue = (float)((unsigned char *)image.data)[k + selectedChannel]/255.0f;
|
||||||
image_alpha = (float)((unsigned char *)image.data)[k + 3]/255.0f;
|
imageAlpha = (float)((unsigned char *)image.data)[k + 3]/255.0f;
|
||||||
|
|
||||||
k += 4;
|
k += 4;
|
||||||
} break;
|
} break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R8G8B8:
|
case PIXELFORMAT_UNCOMPRESSED_R8G8B8:
|
||||||
{
|
{
|
||||||
image_value = (float)((unsigned char *)image.data)[k + selected_channel]/255.0f;
|
imageValue = (float)((unsigned char *)image.data)[k + selectedChannel]/255.0f;
|
||||||
image_alpha = 1;
|
imageAlpha = 1;
|
||||||
|
|
||||||
k += 3;
|
k += 3;
|
||||||
} break;
|
} break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R32:
|
case PIXELFORMAT_UNCOMPRESSED_R32:
|
||||||
{
|
{
|
||||||
image_value = ((float *)image.data)[k];
|
imageValue = ((float *)image.data)[k];
|
||||||
image_alpha = 1;
|
imageAlpha = 1;
|
||||||
|
|
||||||
k += 1;
|
k += 1;
|
||||||
} break;
|
} break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R32G32B32:
|
case PIXELFORMAT_UNCOMPRESSED_R32G32B32:
|
||||||
{
|
{
|
||||||
image_value = ((float *)image.data)[k + selected_channel];
|
imageValue = ((float *)image.data)[k + selectedChannel];
|
||||||
image_alpha = 1;
|
imageAlpha = 1;
|
||||||
|
|
||||||
k += 3;
|
k += 3;
|
||||||
} break;
|
} break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R32G32B32A32:
|
case PIXELFORMAT_UNCOMPRESSED_R32G32B32A32:
|
||||||
{
|
{
|
||||||
image_value = ((float *)image.data)[k + selected_channel];
|
imageValue = ((float *)image.data)[k + selectedChannel];
|
||||||
image_alpha = ((float *)image.data)[k + 3];
|
imageAlpha = ((float *)image.data)[k + 3];
|
||||||
|
|
||||||
k += 4;
|
k += 4;
|
||||||
} break;
|
} break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R16:
|
case PIXELFORMAT_UNCOMPRESSED_R16:
|
||||||
{
|
{
|
||||||
image_value = HalfToFloat(((unsigned short *)image.data)[k]);
|
imageValue = HalfToFloat(((unsigned short *)image.data)[k]);
|
||||||
image_alpha = 1;
|
imageAlpha = 1;
|
||||||
|
|
||||||
k += 1;
|
k += 1;
|
||||||
} break;
|
} break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R16G16B16:
|
case PIXELFORMAT_UNCOMPRESSED_R16G16B16:
|
||||||
{
|
{
|
||||||
image_value = HalfToFloat(((unsigned short *)image.data)[k+selected_channel]);
|
imageValue = HalfToFloat(((unsigned short *)image.data)[k+selectedChannel]);
|
||||||
image_alpha = 1;
|
imageAlpha = 1;
|
||||||
|
|
||||||
k += 3;
|
k += 3;
|
||||||
} break;
|
} break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R16G16B16A16:
|
case PIXELFORMAT_UNCOMPRESSED_R16G16B16A16:
|
||||||
{
|
{
|
||||||
image_value = HalfToFloat(((unsigned short *)image.data)[k + selected_channel]);
|
imageValue = HalfToFloat(((unsigned short *)image.data)[k + selectedChannel]);
|
||||||
image_alpha = HalfToFloat(((unsigned short *)image.data)[k + 3]);
|
imageAlpha = HalfToFloat(((unsigned short *)image.data)[k + 3]);
|
||||||
|
|
||||||
k += 4;
|
k += 4;
|
||||||
} break;
|
} break;
|
||||||
|
|
@ -1844,19 +1849,19 @@ Image ImageFromChannel(Image image, int selected_channel, float threshold)
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify threshold
|
// verify threshold
|
||||||
unsigned char result_value = 0;
|
unsigned char resultValue = 0;
|
||||||
unsigned char result_alpha = 0;
|
unsigned char resultAlpha = 0;
|
||||||
if (image_value >= threshold)
|
if (imageValue >= threshold)
|
||||||
{
|
{
|
||||||
result_value = image_value * 255;
|
resultValue = imageValue * 255;
|
||||||
if (image_alpha)
|
if (imageAlpha)
|
||||||
{
|
{
|
||||||
result_alpha = 255;
|
resultAlpha = 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pixels[i] = result_value;
|
pixels[i] = resultValue;
|
||||||
pixels[i + 1] = result_alpha;
|
pixels[i + 1] = resultAlpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user