Archived

This topic is now archived and is closed to further replies.

DirectX 7 Bitmap Rotation Algorithim.

This topic is 5780 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. Before I get shouted at about this, let me first explain that I have done my research, and know that most graphics cards do not support 2d rotation. I do not want to use direct3d yet, to rotate the bitmap, cause I am only writing a small puzzle game that only has 1 rotation component, and since it is a puzzle game, it is not fast action, therefore speed in no a neccessary. I am willing to write my own function for rotation the bitmap, but have a question. A while back I wrote a function to do the same, in Dos, but for this the bitmap info was held in an int array, with each element holding an index into the palette. Now in Direct X the info is held in a surface, and I have no palette defined, so how do I access the colour of a particular pixel from the surface? Thats about it. Thanks Giant "Only two things are infinite, the universe and human stupidity, and I''m not sure about the former." --Albert Einstein

Share this post


Link to post
Share on other sites
You need to lock the surface, then obtain the lpSurface from the DDSURFACEDESC2 struct used in the lock. This points to the pixels, which are 1,2 or 4 bytes depending on the pixel format. This and the height & width are in the "ddsd" struct.

I suggest blitting from an original rather than rotating the same area multiple times. I used a similar technique for small areas - typically cockpit instruments.

Share this post


Link to post
Share on other sites
Hi.
THanks for your reply.

I dont fully understand what you mean by
quote:

"I suggest blitting from an original rather than rotating the same area multiple times. I used a similar technique for small areas - typically cockpit instruments.



Could you explain?

Thanks
Giant

"Only two things are infinite, the universe and human stupidity, and I''m not sure about the former." --Albert Einstein

Share this post


Link to post
Share on other sites
The fastest way is this:

lock the surface

rotate three point:

  

1 ----- 2
|
|
|
3

So that you get for example:

1
/ \
/ \
/ \
3 2



ok the ACHII image is not so good.

But the point is that then you follow the line 1 - 3 and for each pixel draw a parallel line to 1 - 2

See?

That''s the fastest way possible in software(as far as I know)

I have a demo of it I could maybe send you or something.

Good luck!

PS. you know you rotate points with sin/cos?

/MindWipe

"If it doesn''t fit, force it; if it breaks, it needed replacement anyway."

Share this post


Link to post
Share on other sites
Hi MindWipe.
Thanks for the info. I think i undrestand what you are talking about. I do know about sin/cos. I have rotated before but not surfaces. A demo would be great, if you are willing to share it. My e-mail address is ciaran_mccormack@yahoo.co.uk, while in the mean time I will try and do what you said, about the 3 points.

Thanks Again
Giant

"Only two things are infinite, the universe and human stupidity, and I''m not sure about the former." --Albert Einstein

Share this post


Link to post
Share on other sites