Rotate bmp

Ok, so I have a rectangle shaped image. I want to be able to rotate it
between 0 and 90 degrees. How do I do this?

-Jamie

Hey Jamie,

You’ll surely get lots of other answers but mine is to use OpenGL if your
developing for a platform that can use it (which should be almost all)

With OpenGL, when you do rotations it uses hardware acceleration to do super
fast rotation that is easy on the CPU (not to mention all sorts of other
hardware acceleration like skewing, tinting, transparency etc).> ----- Original Message -----

From: jbernier@mcla.edu (Jamie Bernier)
To:
Sent: Tuesday, April 12, 2005 4:35 PM
Subject: [SDL] rotate bmp

Ok, so I have a rectangle shaped image. I want to be able to rotate it
between 0 and 90 degrees. How do I do this?

-Jamie


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Jamie Bernier wrote:

Ok, so I have a rectangle shaped image. I want to be able to rotate it
between 0 and 90 degrees. How do I do this?

If you onlu need to rotate 90 degress, you could easily modify
surface->pixels directly.

Otherwise there is the SDL_gfx library.

Load your image as a texture in a 3D library and then rotate a 2D
square with the texture applied to it. This is the fastest way and
there is no math involved.

:o)On 4/12/05, Mikael Eriksson wrote:

Jamie Bernier wrote:

Ok, so I have a rectangle shaped image. I want to be able to rotate it
between 0 and 90 degrees. How do I do this?

If you onlu need to rotate 90 degress, you could easily modify
surface->pixels directly.

Otherwise there is the SDL_gfx library.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Of course, if you want to do things by hand, it’s really fun (btw, I
tend to have rather masochistic ideas of when in regards to
programming)!

Anyway, here are a couple of links which may not be exactly what you’re
looking for, but may lead you in the right direction:

http://www.gamedev.net/reference/articles/article811.asp
http://www.codeproject.com/bitmap/rotatebyshear.asp

I think there are downloadable source files, or email addresses for
each of these links’ code.

Good luck!
–ScottOn 12 Apr, 2005, at 5:35 PM, Jamie Bernier wrote:

Ok, so I have a rectangle shaped image. I want to be able to rotate it
between 0 and 90 degrees. How do I do this?

-Jamie


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hello Jamie,

I suggest you to try SDL_gfx library
http://www.ferzkopp.net/~aschiffler/Software/SDL_gfx-2.0/ for rotation
funtions. It also has simple 2d drawing functions like line rectangle,
ellipse. The rotation code is probably not optimised for 90* , 180* or 270*
rotations. But you can easily adopt it.

Hehe, for some value of “all” that doesn’t include most cellphones,
Zaurus PDAs, the Sega Genesis, older Macs, etc. ;^)

(Sorry, can never resist!)

-bill!On Tue, Apr 12, 2005 at 05:40:06PM -0700, Alan Wolfe wrote:

Hey Jamie,

You’ll surely get lots of other answers but mine is to use OpenGL if your
developing for a platform that can use it (which should be almost all)

I should have qualified my statement better, “almost all” based on most
commonly used targets of sdl heheh

PS sdl does sega genesis? that is pretty amazing wow! (:> ----- Original Message -----

From: nbs@sonic.net (Bill Kendrick)
To: "A list for developers using the SDL library. (includes SDL-announce)"

Sent: Wednesday, April 13, 2005 10:39 AM
Subject: Re: [SDL] rotate bmp

On Tue, Apr 12, 2005 at 05:40:06PM -0700, Alan Wolfe wrote:

Hey Jamie,

You’ll surely get lots of other answers but mine is to use OpenGL if
your

developing for a platform that can use it (which should be almost all)

Hehe, for some value of “all” that doesn’t include most cellphones,
Zaurus PDAs, the Sega Genesis, older Macs, etc. ;^)

(Sorry, can never resist!)

-bill!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Ok, well I downloaded and created the SDL_gfx libraries. I placed the
libraries for dev-cpp in the libraries folder and placed the .h gfx files
within the folder that contains the SDL header files. I included the lib
in my project and #include <SDL/SDL_rotozoom.h>. When I compile the
program with this line of code:

SDL_Surface *turret;
turret = rotozoomSurface(turret, .05, 0.0, 1);

I get a linker error:
lesson2.o(.text+0x467):lesson2.cpp: undefined reference to
`_imp__rotozoomSurface’

make.exe: *** ["Lesson] Error 1

Does anyone know what is going wrong?

-Jamie

Seems like a C++ linkage issue: do you have the SDL_gfx headers
wrapped with ‘extern “C” {’ ?

Just to try the concept of SDL_gfx (an easy way) use LuaX, which has
SDL, SDL_image, SDL_gfx and SDL_mixer built-in. The applications are
done as Lua scripts (not much unlike C) so no compilation is ever
required (and linkage issues have already been fixed for you :).

http://luaforge.net/projects/luax/

luax-0.78.tgz and “make” is all you need for Linux, Mac OS X and *BSDs
(the last not well tested, though). Also supports Win32 and PocketPC
2003.

-ak

14.4.2005 kello 04:35, Jamie Bernier kirjoitti:

Ok, well I downloaded and created the SDL_gfx libraries. I placed the> libraries for dev-cpp in the libraries folder and placed the .h gfx

files
within the folder that contains the SDL header files. I included the
lib
in my project and #include <SDL/SDL_rotozoom.h>. When I compile the
program with this line of code:

SDL_Surface *turret;
turret = rotozoomSurface(turret, .05, 0.0, 1);

I get a linker error:
lesson2.o(.text+0x467):lesson2.cpp: undefined reference to
`_imp__rotozoomSurface’

make.exe: *** ["Lesson] Error 1

Does anyone know what is going wrong?

-Jamie


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Ack! Hehe, no! I’m too retro, sorry. :slight_smile: Sega Dreamcast, not Genesis :wink:

-bill!On Wed, Apr 13, 2005 at 11:26:47AM -0700, Alan Wolfe wrote:

I should have qualified my statement better, “almost all” based on most
commonly used targets of sdl heheh

PS sdl does sega genesis? that is pretty amazing wow! (:

Well, I don’t have OpenGL either. My video drivers are not
able to do OpenGL on a 24-bit 1600x1024 display with only 16 MB.
There’s no way I’m going to go below 24-bit. I don’t have an
XFree86 mode line for 800x512, which is probably unsupported by
my driver anyway.

Specs:

Mac G4 Cube
R128 video driver
22" Apple Cinema Display)On Wed, 2005-04-13 at 11:26 -0700, Alan Wolfe wrote:

I should have qualified my statement better, “almost all” based on most
commonly used targets of sdl heheh

My wife’s laptop is a Thinkpad T20, and accelerated 3D is not supported
in the drivers for her video chipset. (Though, since it’s a VIA S3,
that may change soon ;^) See slashdot earlier this week…)

-bill!On Thu, Apr 14, 2005 at 08:27:02PM -0400, Albert Cahalan wrote:

Well, I don’t have OpenGL either. My video drivers are not
able to do OpenGL on a 24-bit 1600x1024 display with only 16 MB.
There’s no way I’m going to go below 24-bit. I don’t have an
XFree86 mode line for 800x512, which is probably unsupported by
my driver anyway.