浏览代码

implemented fill color TODO in ImageResizeCanvas() (#3720)

pull/3727/head
Lieven Petersen 1年前
committed by GitHub
父节点
当前提交
a820c37ab2
找不到此签名对应的密钥 GPG 密钥 ID: 4AEE18F83AFDEB23
共有 1 个文件被更改,包括 15 次插入1 次删除
  1. +15
    -1
      src/rtextures.c

+ 15
- 1
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++)

正在加载...
取消
保存