Kevin,
I meant no offense.
I was just refering to the original code being in C and yours was a translation of it to BCX.
I meant no offense.
I was just refering to the original code being in C and yours was a translation of it to BCX.
'PBCC5.01 program #COMPILE EXE #BREAK ON #DIM ALL %xWindowSize = 280 %yWindowSize = 280 %xRotateOffset=140 %yRotateOffset=140 FUNCTION PBMAIN () AS LONG LOCAL hInitialBMP,hWindow, hThread AS DWORD LOCAL InitialBMPstring, RotatedBMPstring AS STRING LOCAL x,y,a,xSize,ySize,t1,t2, Oldx,Oldy, QuitAll, lResult AS LONG LOCAL Angle,sina, cosa AS EXT LOCAL file AS STRING LOCAL initial(), rotated() AS LONG file$="logo1.bmp" x = FREEFILE OPEN file$ FOR BINARY AS x GET #x, 19, xSize GET #x, 23, ySize CLOSE x GRAPHIC WINDOW "Rotation test",200,200, %xWindowSize,%yWindowSize TO hWindow GRAPHIC ATTACH hWindow,0 GRAPHIC GET BITS TO RotatedBMPstring GRAPHIC DETACH GRAPHIC BITMAP LOAD file$, xSize&, ySize& TO hInitialBMP GRAPHIC ATTACH hInitialBMP,0 GRAPHIC GET BITS TO InitialBMPstring GRAPHIC DETACH THREAD CREATE RedrawGraphics (hWindow) TO hThread DIM initial&(1 TO xSize&,1 TO ySize&) AT STRPTR(InitialBMPstring)+8 DIM rotated&(1 TO %xWindowSize,1 TO %yWindowSize) AT STRPTR(RotatedBMPstring)+8 LOCAL tc, ts AS EXT t1&=TIMER*100 FOR a& = 0 TO 360 'degrees angle##=a&/(180/3.141592653589) cosa=COS(angle##) sina=SIN(angle##) FOR x&=1 TO %xWindowSize tc = (x& - %xRotateOffset) *cosa + %xRotateOffset -40 ts = -(x& - %xRotateOffset)*sina + %yRotateOffset -70 FOR y& = 1 TO %yWindowSize oldx& =tc + (y& - %yRotateOffset)*sina oldy& =(y& - %yRotateOffset) *cosa + ts IF oldx&>0 AND oldx& < xSize& AND oldy&>0 AND oldy&< ySize& THEN Rotated&(x&,y&) = Initial&(oldx& ,oldy&) ELSE Rotated&(x&,y&) = %WHITE END IF NEXT NEXT GRAPHIC ATTACH hWindow,0 ,REDRAW GRAPHIC SET BITS RotatedBMPstring GRAPHIC DETACH SLEEP 0 NEXT t2&=TIMER*100 PRINT "Time Taken = "(t2&-t1&)/100 PRINT "Frames per second ="; 360/((t2&-t1&)/100 ) QuitAll& =1 THREAD CLOSE hThread TO lResult WAITKEY$ END FUNCTION 'This is a flag intended to cause all otherwise non-terminating threads to quit GLOBAL QuitAll& 'This routine and the main program must use GRAPHIC ATTACH WindowID,0,REDRAW but the main program shouldn't 'issue a GRAPHIC REDRAW command in normal use. Leave that up to this thread. FUNCTION RedrawGraphics(BYVAL WinID AS DWORD) AS DWORD GRAPHIC ATTACH WinID,0,REDRAW DO GRAPHIC REDRAW SLEEP 1 LOOP UNTIL QuitAll& END FUNCTION
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment