summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2020-06-07 12:56:47 +0200
committerraysan5 <[email protected]>2020-06-07 12:56:47 +0200
commitb7d53ce3145e1750e2ed54ed456b43b12fb083ab (patch)
tree1adde91d347c33a37df36a6a7041d0e2d0927c24
parent78c3d619f90619a61b5d17a9ad9b6bfb57da3fe5 (diff)
downloadraylib-b7d53ce3145e1750e2ed54ed456b43b12fb083ab.tar.gz
raylib-b7d53ce3145e1750e2ed54ed456b43b12fb083ab.zip
REVIEWED: ImageToPOT() #1218
Using ImageResizeCanvas()
-rw-r--r--src/textures.c34
1 files changed, 1 insertions, 33 deletions
diff --git a/src/textures.c b/src/textures.c
index b65d7147..e7a7d92e 100644
--- a/src/textures.c
+++ b/src/textures.c
@@ -999,39 +999,7 @@ void ImageToPOT(Image *image, Color fillColor)
int potHeight = (int)powf(2, ceilf(logf((float)image->height)/logf(2)));
// Check if POT texture generation is required (if texture is not already POT)
- if ((potWidth != image->width) || (potHeight != image->height))
- {
- Color *pixels = GetImageData(*image); // Get pixels data
- Color *pixelsPOT = NULL;
-
- // Generate POT array from NPOT data
- pixelsPOT = (Color *)RL_MALLOC(potWidth*potHeight*sizeof(Color));
-
- for (int j = 0; j < potHeight; j++)
- {
- for (int i = 0; i < potWidth; i++)
- {
- if ((j < image->height) && (i < image->width)) pixelsPOT[j*potWidth + i] = pixels[j*image->width + i];
- else pixelsPOT[j*potWidth + i] = fillColor;
- }
- }
-
- RL_FREE(pixels); // Free pixels data
- RL_FREE(image->data); // Free old image data
-
- int format = image->format; // Store image data format to reconvert later
-
- // Fill new image data
- image->data = pixelsPOT;
- image->width = potWidth;
- image->height = potHeight;
- image->format = UNCOMPRESSED_R8G8B8A8;
-
- ImageFormat(image, format); // Reconvert image to previous format
-
- // TODO: Verification required for log
- TRACELOG(LOG_WARNING, "IMAGE: Converted to POT: (%ix%i) -> (%ix%i)", image->width, image->height, potWidth, potHeight);
- }
+ if ((potWidth != image->width) || (potHeight != image->height)) ImageResizeCanvas(image, potWidth, potHeight, 0, 0, fillColor);
}
#if defined(SUPPORT_IMAGE_MANIPULATION)