Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rtextures] implemented fill color TODO in ImageResizeCanvas() #3720

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/rtextures.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down