Code: Select all
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
MessageRequester("Error", "Can't open the sprite system", 0)
End
EndIf
UsePNGImageDecoder()
UseJPEGImageDecoder()
wx = 800
wy = 800
If OpenWindow(0, 0, 0, wx, wy, "SpriteMaker", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(0), 0, 0, wx, wy, 0, 0, 0)
file$ = OpenFileRequester("Select an image","", "Image |*.jpg;*.png;*.bmp",0)
imageID = LoadImage(#PB_Any, file$)
Debug imageid
spriteID = CreateSprite(#PB_Any,ImageWidth(imageID),ImageHeight(imageID) , #PB_Sprite_AlphaBlending)
If StartDrawing(SpriteOutput(spriteID))
DrawAlphaImage(ImageID(imageID),0,0)
StopDrawing()
EndIf
Repeat
Event = WindowEvent()
If Event <> 0 ; All events are treated, so we can display the coordinates of the mouse
SetWindowTitle(0, "Position of the mouse on the window: " + Str(WindowMouseX(0)) + "," + Str(WindowMouseX(0)))
Else
Delay(1) ; Without a FlipBuffers(), Delay() frees the CPU for the multitasking
EndIf
DisplaySprite(spriteID,SpriteWidth(spriteID), SpriteHeight(spriteID))
Until Event = #PB_Event_CloseWindow
EndIf
EndIf