Reviewed some functions
- GetImageData() - GetImageDataNormalized()
This commit is contained in:
parent
64804f30e6
commit
372e4a1139
1 changed files with 181 additions and 167 deletions
|
@ -409,6 +409,13 @@ Color *GetImageData(Image image)
|
|||
{
|
||||
Color *pixels = (Color *)malloc(image.width*image.height*sizeof(Color));
|
||||
|
||||
if (image.format >= COMPRESSED_DXT1_RGB) TraceLog(LOG_WARNING, "Pixel data retrieval not supported for compressed image formats");
|
||||
else
|
||||
{
|
||||
if ((image.format == UNCOMPRESSED_R32) ||
|
||||
(image.format == UNCOMPRESSED_R32G32B32) ||
|
||||
(image.format == UNCOMPRESSED_R32G32B32A32)) TraceLog(LOG_WARNING, "32bit pixel format converted to 8bit per channel");
|
||||
|
||||
for (int i = 0, k = 0; i < image.width*image.height; i++)
|
||||
{
|
||||
switch (image.format)
|
||||
|
@ -480,8 +487,6 @@ Color *GetImageData(Image image)
|
|||
} break;
|
||||
case UNCOMPRESSED_R32:
|
||||
{
|
||||
TraceLog(LOG_WARNING, "32bit pixel format converted to 8bit per channel"); break;
|
||||
|
||||
pixels[i].r = (unsigned char)(((float *)image.data)[k]*255.0f);
|
||||
pixels[i].g = 0;
|
||||
pixels[i].b = 0;
|
||||
|
@ -506,7 +511,8 @@ Color *GetImageData(Image image)
|
|||
|
||||
k += 4;
|
||||
}
|
||||
default: TraceLog(LOG_WARNING, "Format not supported for pixel data retrieval"); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -518,6 +524,9 @@ Vector4 *GetImageDataNormalized(Image image)
|
|||
{
|
||||
Vector4 *pixels = (Vector4 *)malloc(image.width*image.height*sizeof(Vector4));
|
||||
|
||||
if (image.format >= COMPRESSED_DXT1_RGB) TraceLog(LOG_WARNING, "Pixel data retrieval not supported for compressed image formats");
|
||||
else
|
||||
{
|
||||
for (int i = 0, k = 0; i < image.width*image.height; i++)
|
||||
{
|
||||
switch (image.format)
|
||||
|
@ -613,7 +622,8 @@ Vector4 *GetImageDataNormalized(Image image)
|
|||
|
||||
k += 4;
|
||||
}
|
||||
default: TraceLog(LOG_WARNING, "Format not supported for pixel data retrieval"); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -792,7 +802,7 @@ void ImageToPOT(Image *image, Color fillColor)
|
|||
// Convert image data to desired format
|
||||
void ImageFormat(Image *image, int newFormat)
|
||||
{
|
||||
if (image->format != newFormat)
|
||||
if ((newFormat != 0) && (image->format != newFormat))
|
||||
{
|
||||
if ((image->format < COMPRESSED_DXT1_RGB) && (newFormat < COMPRESSED_DXT1_RGB))
|
||||
{
|
||||
|
@ -2119,7 +2129,11 @@ Image GenImageCellular(int width, int height, int tileSize)
|
|||
// NOTE: Characters info data should be allocated by user for charsCount
|
||||
Image GenImageFont(const char *fileName, int fontSize, int charsCount, int *fontChars, CharInfo *chars)
|
||||
{
|
||||
Image image = { 0 };
|
||||
|
||||
// TODO.
|
||||
|
||||
return image;
|
||||
}
|
||||
#endif // SUPPORT_IMAGE_GENERATION
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue