REVIEWED: ImageRotate() formatting

This commit is contained in:
Ray
2023-05-26 14:01:19 +02:00
parent 144ae120ab
commit 5ef50ae139

View File

@@ -2132,8 +2132,8 @@ void ImageRotate(Image *image, int degrees)
float sinRadius = sin(rad); float sinRadius = sin(rad);
float cosRadius = cos(rad); float cosRadius = cos(rad);
int width = abs(image->width * cosRadius) + abs(image->height * sinRadius); int width = fabsf(image->width*cosRadius) + fabsf(image->height*sinRadius);
int height = abs(image->height * cosRadius) + abs(image->width * sinRadius); int height = fabsf(image->height*cosRadius) + fabsf(image->width*sinRadius);
int bytesPerPixel = GetPixelDataSize(1, 1, image->format); int bytesPerPixel = GetPixelDataSize(1, 1, image->format);
unsigned char *rotatedData = (unsigned char *)RL_CALLOC(width*height, bytesPerPixel); unsigned char *rotatedData = (unsigned char *)RL_CALLOC(width*height, bytesPerPixel);
@@ -2145,10 +2145,10 @@ void ImageRotate(Image *image, int degrees)
float oldX = ((x - width/2.0f)*cosRadius + (y - height/2.0f)*sinRadius) + image->width/2.0f; float oldX = ((x - width/2.0f)*cosRadius + (y - height/2.0f)*sinRadius) + image->width/2.0f;
float oldY = ((y - height/2.0f)*cosRadius - (x - width/2.0f)*sinRadius) + image->height/2.0f; float oldY = ((y - height/2.0f)*cosRadius - (x - width/2.0f)*sinRadius) + image->height/2.0f;
if (oldX >= 0 && oldX < image->width && oldY >= 0 && oldY < image->height) if ((oldX >= 0) && (oldX < image->width) && (oldY >= 0) && (oldY < image->height))
{ {
int x1 = (int)floor(oldX); int x1 = (int)floorf(oldX);
int y1 = (int)floor(oldY); int y1 = (int)floorf(oldY);
int x2 = MIN(x1 + 1, image->width - 1); int x2 = MIN(x1 + 1, image->width - 1);
int y2 = MIN(y1 + 1, image->height - 1); int y2 = MIN(y1 + 1, image->height - 1);