No, lots of options. Here's one:
Code: Select all
;==================================================
; Program: GDIPlus Rotation Demo
; Author: netmaestro
; Date: July 2, 2009
;==================================================
CompilerIf Defined(GdiplusStartupInput, #PB_Structure) = 0
Structure GdiplusStartupInput
GdiPlusVersion.l
*DebugEventCallback.Debug_Event
SuppressBackgroundThread.l
SuppressExternalCodecs.l
EndStructure
CompilerEndIf
#background = 0 ; image# for background
Prototype GdiplusStartup( *token, *input, mode )
Prototype GdipCreateBitmapFromFile(filename.p-bstr, *image)
Prototype GdipCreateFromHDC( hdc, *gfx)
Prototype GdipRotateWorldTransform( *gfx, angle.f, mode)
Prototype GdipResetWorldTransform( *gfx)
Prototype GdipTranslateWorldTransform( *gfx, wmidf.f, hmidf.f, mode)
Prototype GdipDrawImageRectI( *gfx, *image, x, y, Width, Height )
Prototype GdipDeleteGraphics( *gfx )
Prototype GdipDisposeImage( *image )
Prototype GdiplusShutdown( *token )
OpenLibrary(0, "gdiplus.dll")
Global GdiplusStartup.GdiplusStartup = GetFunction( 0, "GdiplusStartup" )
Global GdipCreateBitmapFromFile.GdipCreateBitmapFromFile = GetFunction( 0, "GdipCreateBitmapFromFile")
Global GdipCreateFromHDC.GdipCreateFromHDC = GetFunction( 0, "GdipCreateFromHDC" )
Global GdipDrawImageRectI.GdipDrawImageRectI = GetFunction( 0, "GdipDrawImageRectI" )
Global GdipRotateWorldTransform.GdipRotateWorldTransform = GetFunction( 0, "GdipRotateWorldTransform" )
Global GdipTranslateWorldTransform.GdipTranslateWorldTransform = GetFunction( 0, "GdipTranslateWorldTransform" )
Global GdipResetWorldTransform.GdipResetWorldTransform = GetFunction( 0, "GdipResetWorldTransform" )
Global GdipDeleteGraphics.GdipDeleteGraphics = GetFunction( 0, "GdipDeleteGraphics" )
Global GdipDisposeImage.GdipDisposeImage = GetFunction( 0, "GdipDisposeImage" )
Global GdiplusShutdown.GdiplusShutdown = GetFunction( 0, "GdiplusShutdown" )
Procedure InitGDIPlus()
input.GdiplusStartupInput
input\GdiPlusVersion = 1
GdiplusStartup( @*token, @input, #Null)
ProcedureReturn *token
EndProcedure
Procedure ShutDownGDIPlus(*token)
GdiplusShutdown(*token)
CloseLibrary(0)
EndProcedure
Procedure RotateImage(*image, bkgimage, angle.f)
width=ImageWidth(bkgimage)
height=ImageHeight(bkgimage)
wmidf.f = width/2
hmidf.f = height/2
wmid.l = height/2
hmid.l = height/2
hdc=StartDrawing(ImageOutput(bkgimage))
GdipCreateFromHDC( hdc, @*surface)
GdipRotateWorldTransform( *surface, angle, 1)
GdipTranslateWorldTransform( *surface, wmidf, hmidf, 1)
GdipDrawImageRectI( *surface, *image, wmid, hmid, -width, -height)
GdipResetWorldTransform( *surface)
StopDrawing()
GdipDeleteGraphics( *surface)
EndProcedure
*token = InitGDIPlus()
GdipCreateBitmapFromFile("513pxwheeloffortuneseas.png", @*wheeldisc)
CreateImage(0,513,513,32)
OpenWindow(0,0,0,540,570,"Rotation Demo",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
SetWindowColor(0,0)
ImageGadget(0,15,15,0,0,0)
ButtonGadget(1,220,540,100,20,"Spin!")
RotateImage(*wheeldisc, #background, 0)
SetGadgetState(0,ImageID(#background))
Repeat
EventID = WindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadget()
Case 1
inc.d = (500+Random(200))/100
EndSelect
EndSelect
If inc
inc - 0.01
If inc<=0
inc=0:spinning=0
intangle=Int(angle.d)
offset=intangle%15
If offset > 7 : angle+(15-offset) : Else : angle-offset : EndIf
Else
angle.d+inc.d:If angle >=360:angle=0:EndIf
EndIf
RotateImage(*wheeldisc, #background, angle)
SetGadgetState(0,ImageID(#background))
EndIf
Until EventID = #WM_CLOSE
ShutDownGDIPlus(*token)