Image rotation with Bos Taurus

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

Post Reply
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Image rotation with Bos Taurus

Post by bluebird »

I would be grateful for any help in my Bos Taurus learning curve.

In the code fragment below, I want to show an arrow symbol called "pointer.jpg" in several different rotated positions on the same form.
The base image un-rotated is a "Vee" shape pointing in a horizontal right direction.

nDegrees is calculated in function AngleX based on the slope of the line from start point nX1,nY1 ending at nX2,nY2
hBitmap2 is the handle to the original "pointer.jpg" image
hBitmap3 is the handle to the image rotated by nDegrees

Question 1. The rotation using BT_BITMAP_ROTATE seems to be clockwise instead of the expected counter-clockwise. Is that observation correct?

Question 2. Am I using BT functions (rotating and showing) correctly according to the code fragment below?

Question 3. If you want to show the image in a new place after a 2nd rotation, do you have to first reset it to the original horizontal position ?


==============================================================================
Code Fragment
===============================================================================
nDegrees:=AngleX(nx1,ny1,nx2,ny2)

hBitmap3:=BT_BitmapTransform (hBitmap2, BT_BITMAP_ROTATE , nDegrees, WHITE) // rotate command
BT_DrawBitmapTransparent (hDC, nRow2-15,nCol2-10, 30, 30, BT_SCALE, hBitmap3) // show rotated image
BT_DrawBitmapTransparent (hDC,50 ,750, 40, 40, BT_SCALE, hBitmap2) // draw unrotated image off to the side

BT_DrawBitmapTransparent (hDC, nRow3-15,nCol3-10, 30, 30, BT_SCALE, hBitmap3) // show rotated image in another place
return

*---------------------------------
Function AngleX(x1,y1,x2,y2)
*--------------------------------
#DEFINE PI 3.1415
#DEFINE FULLCIRCLE 360

Local nAngleInDegrees, nAtanx, nRatio, nCircleRadians:=2*PI

nRatio:=(y2-y1)/(x2-x1)
nATanx:=ATAN(nRatio)

nAngleInDegrees:=nATanx*FULLCIRCLE/nCircleRadians
msgbox("angle is "+str(nAngleInDegrees)+"Deg.")
Return 360-nAngleInDegrees
Post Reply