diff options
| author | Ray <raysan5@gmail.com> | 2019-03-15 00:56:02 +0100 |
|---|---|---|
| committer | Ray <raysan5@gmail.com> | 2019-03-15 00:56:02 +0100 |
| commit | cbfa35a39e2075431aa84ed0c476c39ff3e30adc (patch) | |
| tree | 7f58cfdec980f76869863c0e4b3d0bd6d05c6fcc /src | |
| parent | ff1bcfb2faaf6bfca99ed4b2b2816ba0d24d7647 (diff) | |
| download | raylib-cbfa35a39e2075431aa84ed0c476c39ff3e30adc.tar.gz raylib-cbfa35a39e2075431aa84ed0c476c39ff3e30adc.zip | |
REVIEW: ImageResizeCanvas() -WIP-
Diffstat (limited to 'src')
| -rw-r--r-- | src/textures.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/textures.c b/src/textures.c index 95cb4eb5..070c83f3 100644 --- a/src/textures.c +++ b/src/textures.c @@ -1398,24 +1398,23 @@ void ImageResizeNN(Image *image,int newWidth,int newHeight) // NOTE: Resize offset is relative to the top-left corner of the original image void ImageResizeCanvas(Image *image, int newWidth,int newHeight, int offsetX, int offsetY, Color color) { - Image imTemp = GenImageColor(newWidth, newHeight, color); - Rectangle srcRec = { 0.0f, 0.0f, (float)image->width, (float)image->height }; - Rectangle dstRec = { (float)offsetX, (float)offsetY, (float)srcRec.width, (float)srcRec.height }; - // TODO: Review different scaling situations if ((newWidth > image->width) && (newHeight > image->height)) { + Image imTemp = GenImageColor(newWidth, newHeight, color); + Rectangle srcRec = { 0.0f, 0.0f, (float)image->width, (float)image->height }; + Rectangle dstRec = { (float)offsetX, (float)offsetY, (float)srcRec.width, (float)srcRec.height }; + ImageDraw(&imTemp, *image, srcRec, dstRec); ImageFormat(&imTemp, image->format); UnloadImage(*image); *image = imTemp; } - else + else if ((newWidth < image->width) && (newHeight < image->height)) { - // TODO: ImageCrop(), define proper cropping rectangle - - UnloadImage(imTemp); + Rectangle crop = { (float)offsetX, (float)offsetY, newWidth, newHeight }; + ImageCrop(image, crop); } } |
