Open hydren opened 7 years ago
After digging in the SDL_gfx source, I had a hunch about where the issue is. My guess is that the problem lies at the line 963 of SDL_rotozoom.c
, at the function _rotozoomSurfaceSizeTrig()
. It seems that the zoomy
parameter is not used.
/*
* Determine destination width and height by rotating a centered source box
*/
radangle = angle * (M_PI / 180.0);
*sanglezoom = sin(radangle);
*canglezoom = cos(radangle);
*sanglezoom *= zoomx;
*canglezoom *= zoomx;
x = (double)(width / 2);
y = (double)(height / 2);
cx = *canglezoom * x;
cy = *canglezoom * y;
sx = *sanglezoom * x;
sy = *sanglezoom * y;
Thanks for the bug report. This error seems to be also present in the SDL2_gfx library.
You're welcome! I'm glad to help.
Err... I just tested the previous example with the new SDL_gfx release (both 2.0.26 and 1.0.3) and it seems that unfortunately the issue was not fixed. Now, instead of the unused vertical factor error, the issue seems to be incorrect zooming and sizing.
When both zoomx
and zoomy
are equal, the behavior is correct. But when zoomx != zoomy
, the result seems to be equally hor. and ver. scaled by zoomx
, more or less, and with incorrect sizing, to the point that when zoomx < zoomy
, the image is cropped.
Here are some prints: Normal Scaled horizontally Scaled vertically Scaled horizontally and rotated Scaled vertically and rotated
Taken from a MinGW 4.9.3 build on Windows 7 (32bit).
OK - let me have a look again. Probably zoomx and and zoomy use needs to be flipped.
Hi, any progress on this? Currently, as a workaround, I'm using zoomSurface() then rotozoomSurface() on the result to get the same effect.
The function
rotozoomSurfaceXY()
appears to be using thezoomx
parameter for both horizontal and vertical scaling factor, incorrectly resulting in a behavior similar torotozoomSurface()
. The correct behavior, according to the documentation, is to usezoomx
as horizontal scaling factor andzoomy
as vertical scaling factor.I tested the behavior with SDL_gfx version 2.0.25.
Here is a test code (an image named "sample.bmp" is required):
Compiled with:
gcc main.c -o "test" `sdl-config --cflags --libs` -lSDL_gfx