summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorLieven Petersen <[email protected]>2024-01-11 19:48:14 +0100
committerGitHub <[email protected]>2024-01-11 19:48:14 +0100
commita820c37ab284279230c51a57306e64ad70e7d344 (patch)
treeb47c2339022532c539fc18b56ea9838ae68cf858 /src
parent746f129bfe161c12bed294bd9d8514d8e46517ec (diff)
downloadraylib-a820c37ab284279230c51a57306e64ad70e7d344.tar.gz
raylib-a820c37ab284279230c51a57306e64ad70e7d344.zip
implemented fill color TODO in ImageResizeCanvas() (#3720)
Diffstat (limited to 'src')
-rw-r--r--src/rtextures.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/rtextures.c b/src/rtextures.c
index 738f593c..cdec7a3a 100644
--- a/src/rtextures.c
+++ b/src/rtextures.c
@@ -1741,8 +1741,22 @@ void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, i
int bytesPerPixel = GetPixelDataSize(1, 1, image->format);
unsigned char *resizedData = (unsigned char *)RL_CALLOC(newWidth*newHeight*bytesPerPixel, 1);
- // TODO: Fill resized canvas with fill color (must be formatted to image->format)
+ // Fill resized canvas with fill color
+ // Set first pixel with image->format
+ SetPixelColor(resizedData, fill, image->format);
+ // Fill remaining bytes of first row
+ for (int x = 1; x < newWidth; x++)
+ {
+ memcpy(resizedData + x*bytesPerPixel, resizedData, bytesPerPixel);
+ }
+ // Copy the first row into the other rows
+ for (int y = 1; y < newHeight; y++)
+ {
+ memcpy(resizedData + y*newWidth*bytesPerPixel, resizedData, newWidth*bytesPerPixel);
+ }
+
+ // Copy old image to resized canvas
int dstOffsetSize = ((int)dstPos.y*newWidth + (int)dstPos.x)*bytesPerPixel;
for (int y = 0; y < (int)srcRec.height; y++)