flat assembler
Message board for the users of flat assembler.
Index
> Windows > bitmap rotation alghorithm |
Author |
|
typedef 19 Jan 2013, 20:39
|
|||
19 Jan 2013, 20:39 |
|
dave_30 19 Jan 2013, 21:09
well,to be honest there's tons of examples in vb and c but didn't been able to make the same in fasm or some didn't had what i'm looking for.
i also have several vb codes which does what i want but they draw it first into another dc then rotates the bitmap then transfers it to main dc which isn't what i want. what i want is to include the bitmap and at run time read the bitmap data pixel by pixel and calculate the x and y by an angle then draw it. i can draw the bitmap fine using dib it's the rotation i'm stuck at. |
|||
19 Jan 2013, 21:09 |
|
Siekmanski 20 Jan 2013, 10:23
Here's a very old example I did in the DOS days.
It's in TASM and it uses TRAN's PMODE.
|
|||||||||||
20 Jan 2013, 10:23 |
|
dave_30 21 Jan 2013, 16:29
i used the code from vb and converted it to asm but i don't know why it doesn't works.
here is the code in vb that calculates the x and y based on the angel. Code: Private Function InvRotateCoord(ByVal X As Long, ByVal Y As Long, _ ByVal Xs As Long, ByVal Ys As Long, _ ByVal Angle As Single) As RotateCoordenats Dim SinA As Single, CosA As Single 'convert X,Y screen positions to math positions Xs = Xs / 2 Ys = Ys / 2 X = X - Xs Y = Y - Ys 'convert the angle to angles values Angle = Angle * PI / 180 'calculate the SIN and COS of an angle SinA = Sin(Angle) CosA = Cos(Angle) 'Calculate the X,Y Rotated coordenats InvRotateCoord.RotatedX = Xs + X * CosA - Y * SinA InvRotateCoord.RotatedY = Ys + Y * CosA + X * SinA End Function and here is my code: Code: cvtsi2ss xmm0,[width] cvtsi2ss xmm1,[height] cvtsi2ss xmm2,[x] cvtsi2ss xmm3,[y] cvtsi2ss xmm4,[Angel] fld1 fadd st0,st0 fstp [vd] divss xmm0,[vd] divss xmm1,[vd] subss xmm2,xmm0 subss xmm3,xmm1 mulss xmm4,[PI] divss xmm4,[_2PI] movss [Angel],xmm4 fld [Angel] fsincos fstp [cosa] fstp [sina] addss xmm0,xmm2 mulss xmm0,[cosa] subss xmm0,xmm3 mulss xmm0,[sina] addss xmm0,xmm2 cvtss2si eax,xmm0 mov [nx],eax addss xmm1,xmm3 mulss xmm1,[cosa] addss xmm1,xmm2 mulss xmm1,[sina] addss xmm1,xmm3 cvtss2si eax,xmm1 mov [ny],eax i don't know why the fuck it doesn't works?! |
|||
21 Jan 2013, 16:29 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.