Skip to main content
GameDev.net gamedev.net
🔒 Locked

flipping bitmap

Started by unknownProdigy Oct 12, 2005 at 6:33 AM 2 replies 650+ views
Original Post
unknownProdigy
unknownProdigy
This is a C++/win32 question. If I had a HBITMAP, how do I flip it? ALso, how do I rotate an image? If it is possible to rotate an image, I prefer it shown in degrees rather than radians.
DangerDave
DangerDave
OK, flipping is easy. I'm pretty sure you can just set a negative width/height when you BitBlt and it will flip it.

Rotation is more complicated. Basically the only way to do it on the fly is to GetPixel and SetPixel, one pixel at a time, rotating as you go. Very very slow. If you intend to use in a game it wont pan out.

A mid-way alternative is to have seperate images for each possible rotation, so you could use the GetPixel and SetPixel method to generate each possible rotation and save them for use later.

The best way is to use DirectX or OpenGL and make use of the 3D hardware in computers. You map the image to rotate onto a 3D square (i.e. a textured quad) that is set to always face you (so 2D) and use built-in matrix rotate functions on the quad -- nice and fast.

Without knowing the application cant really go into more detail.

Hope this helps.


Dave.
Anon Mike
Anon Mike
You don't need to manually calculate very pixels to do rotations.

SetWorldTransform is the best pure GDI way to do arbitrary 2d rotations. You can also use PlgBlt.
-Mike

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.