Rotating a Bitmap

Started by
21 comments, last by Drizzt DoUrden 21 years, 8 months ago
Well here I am, trying to rotate a bitmap . I remembered seeing a library called "rotozoom" on the main SDL page, but it only works with Linux (supposedly). So what am I supposed to do? Write my own function? If so, how? Is there a function in SDL that I can use (I don''t see any in the Doc Project). I feel pretty wierd asking a question like this, newbyish? I''m used to glRotatef(), so I''m pretty stumped here. Thanks for any responses. ------------------------------ Simple DirectMedia Layer:
Main Site - (www.libsdl.org) Cone3D Tutorials- (cone3D.gamedev.net) GameDev.net''s Tutorials - (Here)
OpenGL:
Main Site - (www.opengl.org) NeHe Tutorials - (nehe.gamedev.net) Online Books - (Red Book) (Blue Book)
------------------------------Put THAT in your smoke and pipe it
Advertisement
*bump*

It's really bothering me. Really .

Edited by - Drizzt DoUrden on February 19, 2002 6:55:55 PM
------------------------------Put THAT in your smoke and pipe it
Check out SDL_gfx

"Don''t be afraid to dream, for out of such fragile things come miracles."
Hey,
I don''t remember where it is, but there''s an article on the net (not GameDev) devoted to software rotation of images.

It''s not particularly fun, nor is it particularly fast; but if you must do it, I suggest looking for it.

--Nairb
quote:Original post by Redleaf
Check out SDL_gfx

Yeah Readleaf - that''s what I''m using. Drizzt, this library (SDL_gfx) contains a rotozoomSurface() function that you can use in Windows - I''ve used it sucessfully. It''s nothing complex, but email me if you run into any problems. Just be sure to #include "sdl_rotozoom.h" as well as place the sdl_rotozoom.c in your project so you don''t get nasty link errors



_________________________________________________________________

Drew Sikora
A.K.A. Gaiiden

ICQ #: 70449988
AOLIM: DarkPylat

Blade Edge Software
Staff Member, GDNet
Public Relations, Game Institute

3-time Contributing author, Game Design Methods , Charles River Media (coming April/May 2002)
Online column - Design Corner at Pixelate

NJ IGDA Chapter - NJ developers unite!! [Chapter Home | Chapter Forum]

Drew Sikora
Executive Producer
GameDev.net

for (x,y) = pixel on the target bitmap T   figure out (x0,y0) whence in the source bitmap S   the pixel T(x,y) comes from   ( e.g. x0 = cos(-angle)*x,           y0 = sin(-angle)*y,      if you arer centered at (0,0) )   plot the pixel at T(x,y) with the color from S(x0,y0),   possibly with supersampling    (e.g. averaging the neighbouring colors) 
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Maybe it is a rare deficiency of SDL, the lack of hardware scaling and rotation.
Well, who knows, maybe it will be included in a future version.
quote:Original post by Gaiiden
Yeah Readleaf - that's what I'm using. Drizzt, this library (SDL_gfx) contains a rotozoomSurface() function that you can use in Windows - I've used it sucessfully. It's nothing complex, but email me if you run into any problems. Just be sure to #include "sdl_rotozoom.h" as well as place the sdl_rotozoom.c in your project so you don't get nasty link errors


The problem here is that it still uses SDL_rotozoom. SDL_gfx just has SDL_rotozoom as part of it, and SDL_rotozoom only works for Linux. Or is the rotozoom in SDL_gfx completely different?

[EDIT] - looked at SDL_rotozoom.c:
They include "windows.h" in SDL_rotozoom.c. This means that the rotation will only work in windows correct?
[/EDIT]

------------------------------
Simple DirectMedia Layer:

Main Site - (www.libsdl.org)
Cone3D Tutorials- (cone3D.gamedev.net)
GameDev.net's Tutorials - (Here)

OpenGL:

Main Site - (www.opengl.org)
NeHe Tutorials - (nehe.gamedev.net)
Online Books - (Red Book) (Blue Book)


Edited by - Drizzt DoUrden on February 20, 2002 3:33:31 PM
------------------------------Put THAT in your smoke and pipe it
It is not a deficiency of sdl, they focus more on platform independence then on feature richness. They don''t claim to be a complete game engine.....

BTW, the library SGE (SDL Graphics Extention) claims to do rotation and transformation, but i haven''t tried it.....
quote:Original post by Drizzt DoUrden
The problem here is that it still uses SDL_rotozoom. SDL_gfx just has SDL_rotozoom as part of it, and SDL_rotozoom only works for Linux. Or is the rotozoom in SDL_gfx completely different?

[EDIT] - looked at SDL_rotozoom.c:
They include "windows.h" in SDL_rotozoom.c. This means that the rotation will only work in windows correct?
[/EDIT]

Yeah, but you''ll notice that they encase the windows include in an #ifdef directive, so that only if the code is being used on a Win32 platform is the header included. Will you just go ahead and use it already?? It works! Yeesh, hee hee

Drew Sikora
Executive Producer
GameDev.net

This topic is closed to new replies.

Advertisement