PDA

View Full Version : Rotating bitmaps



DrT
11-08-2003, 07:10 AM
Hi,

I've been using a DxDraw surface and ImageList.Draw and/or StretchDraw to draw bitmaps onto it quite happily. However, I need to rotate a bitmap from my ImageList when I draw it on the surface. I tried to use ImageList.DrawRotate but nothing seems to appear on the desktop. Can anyone help?

Thanks

Tim

Traveler
11-08-2003, 07:19 AM
One of the samples that came with DelphiX includes a rotation demo, if I remember correctly.

If that doesn't help, show us some code, because right now, we don't know what your doing wrong.

Avatar
11-08-2003, 11:32 AM
Is you create srpites with the dxSpriteEngine of DelphiX there is a class that allows you to rotate your bitmaps. Instead of creating a TImageSprite you can create a TImageSpriteEx which has 2 new properties : Angle and alpha(no need to explain) . The huge drawback of that class is that your sprite wont be animed if you use this.

This can be pretty useful :) . However there are tuts to make rotation of your sprites ... And if it doesn't work, you still have the possibility to make a rotation by hand and stock it in your dxImagelist !

Useless Hacker
11-08-2003, 08:34 PM
ImageList.DrawRotate should work, probably you are passing in the wrong parameters (What are you setting centreX and centreY to? You should normally use 0.5).
Otherwise, like Traveler says, post your code.

DrT
12-08-2003, 06:32 AM
Thanks for the replies guys, the 0.5 for CentreX and CentreY was the answer. I assumed CentreX and CentreY was the pixel coordinate of where on the image it was to take as the center!

Thanks again.

Useless Hacker
12-08-2003, 12:52 PM
No problem, DrT, I always make that mistake!

Kamaz
10-10-2003, 09:59 AM
However, the problem I encountered me myself. Have to admit, those 0.5 was really annoying, but then everything went more or less smooth..until..until I decided to rotate more than one bitmap. It ended up by decrese in FPS. From constant 75 til 52 with two bitmaps and 38 with 3-5 and even less by greater count. That I could not tolarate, so I decided to rotate just bitmap and then use it as sprite animation. For this purpose I modified a little this program (http://www.efg2.com/Lab/ImageProcessing/RotateScanline.htm) adding the option to create/save to file sprite of multiple rotations. At the moment it seems working, though, I am not quiet satisfied because the increase in speed (its allways 75 by any number of sprites on screen) is compensated by the slowdown (fantastic slowdown, acctually, if I want to use 255 frame rotation per 2*PI angle) in startup. Are there any other ways to speed up the applications but with reasonable startup time? Or is it just - no pain no gain?

And, BTW, where can I find some more explicable help files rather than those default that come with DelphiX package?

davidluo188
01-04-2004, 09:08 AM
but when i rotate bitmap. the collision detect works bad(i set PixelCheck := True;) :-(