PDA

View Full Version : Bitmap Rotation



peter
20-11-2013, 23:13
Hi,


This is a bitmap rotation test.
My rotation algorithm isn't hardware and for this reason not fast enough.


Is there anyone who knows a faster algorithm?


Uses "ui","math"
#INCLUDE "abc.inc"


DWord hdc, hwnd
hwnd = Canvas_Window("ROTATE",xMiddle(400),yMiddle(240),400,240)
Canvas_Attach(hwnd,0,%TRUE)


hdc = Canvas_GetDC()
SetHandleDC hdc
SetFont 18,18,%FW_BOLD,""


Dim av(6) As Single
Dim aw(6) As Single
Long b2, x, y


For x=1 To 6
av(x) = Rand(6,10)
aw(x) = av(x)
Next


b2 = LoadBmp "img/angel.bmp",1


While IsWindow(hwnd) And KeyDown(27)=0
Canvas_Clear 0
For x=1 To 6
RotBitmap b2,x*64-64,y*64+60,av(x)
RotBitmap b2,x*64-64,y*64+130,-av(x)
Next

For x=1 To 6
av(x) += aw(x)
If av(x) >=360 Then av(x)= aw(x)
Next

DrawText 60,20,"BITMAP ROTATION",255+255*256+255*65536
Canvas_Redraw
'Sleep 10
Wend
FreeGraphic
Canvas_Window End

mike lobanovsky
22-11-2013, 10:19
Hi Peter,

1. I'm sorry to say it but your code is again incompatible with the contents of your zip. Please fix

b2 = LoadBmp "img/angel.bmp",1
to

b2 = LoadBmp ".\bmp\angel.bmp",1
or you're likely to be waiting for an answer to your questions until the Second Coming...:)

2. Your code doesn't contain any "algorithm". The algorithm is in fact hidden in the black box called "abc.dll".

3. By my personal experience, you won't be able to rotate a picture real fast and smoothly irrespective of its size unless abc.dll implements its rotation algorithm, whatever it is, in highly optimized hand-written assembly or is at least compiled by a really intelligent static C compiler capable of optimizing C code written with such an optimization in mind. Then rotation can be made not only smooth and fast but also anti-aliased. Either way, programmatic rotation is unlikely to have FPS rates higher than perhaps a hundred frames per second for a single picture, to say nothing of rotating a dozen pictures simultaneously.

4. You can break that barrier programmatically only if you use hardware-assisted DirectX or OpenGL implementations, which is of course beyond the scope of this topic.

5. The only feasible way out of the situation under the circumstances is to use sprites that have detailed rotation phases pre-rendered.

Hope that answers your question. A negative answer is also an answer of a sort.:)

peter
22-11-2013, 12:57
Hello Mike,


You can break that barrier programmatically only if you use hardware-assisted DirectX or OpenGL implementations


DirectX or OpenGl, no problem, but i am a (Do it yourself) programmer.


I'm sorry to say it but your code is again incompatible with the contents of your zip


Next times, I will take `.rar :D
To be honest, I have no problems with the content of a zip file.


I put everything in my ThinBasic directory, and I do not know this problems, what you are telling here.

mike lobanovsky
22-11-2013, 14:14
Peter,



I'm sorry to say it but your code is again incompatible with the contents of your zip
Next times, I will take `.rar :D
To be honest, I have no problems with the content of a zip file.

It seems you do not understand the true meaning of my remark. It is not a question of a ZIP or a RAR or an ARC or a PAK or a 7Z. I can uncompress any of them, and much more. But when I do uncompress them, I am not supposed to debug your code which you publish here in order to make it compatible with the internal structure of the archive which you also attach here your own self. The maximum you can expect of me, or any other forum member, is click your script file to see if it runs at all. If it doesn't, then it is entirely my own choice if I continue looking into it or not. In order for me to be willing to spend more of my time and continue looking into it, I must be perfectly sure you did everything you could to avoid or amend your own bugs and typos. But if all I'm seeing is just pure neglect of the subject matter of my messages here and here: http://www.thinbasic.com/community/showthread.php?t=12283&p=90291#post90291 , then I will most probably lack interest in any further discussion.


I put everything in my ThinBasic directory, and I do not know this problems, what you are telling here.

But you shouldn't expect me to be equally happy about bloating my TB directory with code and executable modules of unknown origin and questionable quality.

Now let me tell you once again, here and now, the code you published is not going to run on your PC either, whether you put everything in your TB directory or not, until you either 1. change your "img/angel.bmp" to at least "bmp\angel.bmp"; or 2. rename the \Bmp directory in your zip to \Img. But do not expect me to do it for you. It would have been much more natural if you did it for me and everybody else before commenting on my message.


DirectX or OpenGl, no problem, but i am a (Do it yourself) programmer.

Let me assure you there is a problem with either of these for a self-made programmer. So your best bet would be to consider TBGL and start learning it by the excellent examples which are plentiful both on this forum and in the distro.


Regards,

peter
22-11-2013, 15:32
Dear Mike,


I am not willing to change something, what I have done in the last 100 years.
If you do not like it, don't read my source code. (post)


I am really not your enemy, who sends you heavy puzzles.
This theme ends now here.

Billbo
22-11-2013, 17:16
Peter,

Why do you name all your attachments "abc.zip?" You posted
one yesterday with different content.

Bill

peter
22-11-2013, 17:53
Billbo,

Why not ? Is the same like def.zip or xyz.zip

Billbo
22-11-2013, 19:05
Peter,

The files def.zip and xyz.zip are not the same.

Just because you have 316 posts does not make me stupid.
The files def.zip or xyz.zip have the same extensions, but
not the same file names. I was speaking of the "abc."

What does a abc.zip of 16kb+ and an abc.zip of 206kb+
have in common? Doesn't tell you crap other than the two
have the same name and different size; and you can't
put them in the same directory.

Ever wonder why programs have version numbers?

I do not appreciate what I read as an implied insult.

Bill

zlatkoAB
22-11-2013, 19:41
i think that i need oxygen...he..he:D:D

peter
22-11-2013, 21:57
damned,


Is a little bit unfriendly here, I think.
The name "abc.zip" is always identic, because its content has always the new updated "abc.dll" and "abc.inc".


There is no need for another name.
You unzip this "abc.zip" and put it into your directory, where you have your ThinBasic or something else.


Do not put this "abc.zip" in your directory!
By the way, I have heard your unfriendliness. I am not your punster!

Billbo
23-11-2013, 01:44
Peter,

Thank you for your explanation. I was not trying
to be unfriendly; thought my toes were being stepped
on.

Thanks,

Bill