mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-13 06:48:15 +00:00
Simplified some code
This commit is contained in:
@@ -575,14 +575,10 @@ void UpdateTexture(Texture2D texture, const void *pixels)
|
|||||||
// Export image as a PNG file
|
// Export image as a PNG file
|
||||||
void ExportImage(const char *fileName, Image image)
|
void ExportImage(const char *fileName, Image image)
|
||||||
{
|
{
|
||||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
|
|
||||||
// NOTE: Getting Color array as RGBA unsigned char values
|
// NOTE: Getting Color array as RGBA unsigned char values
|
||||||
unsigned char *imgData = (unsigned char *)GetImageData(image);
|
unsigned char *imgData = (unsigned char *)GetImageData(image);
|
||||||
SavePNG(fileName, imgData, image.width, image.height, 4);
|
SavePNG(fileName, imgData, image.width, image.height, 4);
|
||||||
free(imgData);
|
free(imgData);
|
||||||
|
|
||||||
TraceLog(LOG_INFO, "Image saved: %s", fileName);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy an image to a new image
|
// Copy an image to a new image
|
||||||
@@ -1930,12 +1926,8 @@ Image GenImageCellular(int width, int height, int tileSize)
|
|||||||
void GenTextureMipmaps(Texture2D *texture)
|
void GenTextureMipmaps(Texture2D *texture)
|
||||||
{
|
{
|
||||||
#if defined(PLATFORM_WEB)
|
#if defined(PLATFORM_WEB)
|
||||||
// Calculate next power-of-two values
|
|
||||||
int potWidth = (int)powf(2, ceilf(logf((float)texture->width)/logf(2)));
|
|
||||||
int potHeight = (int)powf(2, ceilf(logf((float)texture->height)/logf(2)));
|
|
||||||
|
|
||||||
// Check if texture is POT
|
// Check if texture is POT
|
||||||
if ((potWidth != texture->width) || (potHeight != texture->height))
|
if (((texture->width & (texture->width - 1)) != 0) || ((texture->height & (texture->height - 1)) != 0))
|
||||||
{
|
{
|
||||||
TraceLog(LOG_WARNING, "Limited NPOT support, no mipmaps available for NPOT textures");
|
TraceLog(LOG_WARNING, "Limited NPOT support, no mipmaps available for NPOT textures");
|
||||||
}
|
}
|
||||||
|
@@ -141,13 +141,14 @@ void TraceLog(int msgType, const char *text, ...)
|
|||||||
#endif // SUPPORT_TRACELOG
|
#endif // SUPPORT_TRACELOG
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
|
|
||||||
|
|
||||||
#if defined(SUPPORT_SAVE_BMP)
|
#if defined(SUPPORT_SAVE_BMP)
|
||||||
// Creates a BMP image file from an array of pixel data
|
// Creates a BMP image file from an array of pixel data
|
||||||
void SaveBMP(const char *fileName, unsigned char *imgData, int width, int height, int compSize)
|
void SaveBMP(const char *fileName, unsigned char *imgData, int width, int height, int compSize)
|
||||||
{
|
{
|
||||||
|
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
|
||||||
stbi_write_bmp(fileName, width, height, compSize, imgData);
|
stbi_write_bmp(fileName, width, height, compSize, imgData);
|
||||||
|
TraceLog(LOG_INFO, "BMP Image saved: %s", fileName);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -155,9 +156,11 @@ void SaveBMP(const char *fileName, unsigned char *imgData, int width, int height
|
|||||||
// Creates a PNG image file from an array of pixel data
|
// Creates a PNG image file from an array of pixel data
|
||||||
void SavePNG(const char *fileName, unsigned char *imgData, int width, int height, int compSize)
|
void SavePNG(const char *fileName, unsigned char *imgData, int width, int height, int compSize)
|
||||||
{
|
{
|
||||||
|
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
|
||||||
stbi_write_png(fileName, width, height, compSize, imgData, width*compSize);
|
stbi_write_png(fileName, width, height, compSize, imgData, width*compSize);
|
||||||
}
|
TraceLog(LOG_INFO, "PNG Image saved: %s", fileName);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Keep track of memory allocated
|
// Keep track of memory allocated
|
||||||
|
Reference in New Issue
Block a user