If your goal is to optimize your application (rotating a smaller area,
not having to crop the resulting surface) then as you may already
suspect, your new approach is a little long-winded.
If you look into the SDL_Gfx source code and find the rotation
function, it may not be difficult (even for a novice) to rewrite it
into a new function which has the following characteristics:
A) Returns a surface with the same dimensions as the source
B) Simply throws away information that would end up outside the
boundaries of the destination surface
On the other hand, if your goal is merely to cut out a circular area
of an image you also want rotated, your way seems reasonable.
If you’re feeling more daring, you can try to add this characteristic
to your new rotation function:
C) Only process pixels a certain distance from the center
Also, IIRC, SDL_Gfx comes with a function to draw a filled circle, can
that be used to generate your mask? It’s probably faster than scaling
an existing image of a circle.
Also also, some day you may want to try programming with OpenGL.
Rotation is a rather trivial operation for modern GPUs.On Sat, Dec 13, 2008 at 1:14 PM, Neil White wrote:
i would like to be able to rotate a circular area of a surface, returning
a rotated circular section of a surface in a masked square surface.
I think i figured out a way to do this now, but i’m sure some of you lot
will say i’m crazy… using a large b&w circle outline, scale it down to the
size of the area i want to rotate, get area i want to rotate in new surface,
rotate it , then use circle mask to create new surface with masked circle
outline.
–
http://codebad.com/