EncodeSprite()
Posted: Thu Mar 28, 2024 2:49 am
Hello,
I wish to get the function EncodeSprite(), which converts a sprite into an image. For now, when taking a screenshot from a screen (opened with OpenScreen()) I have to grab the sprite and save it on disk, then reload it. This is suboptimal:
Couldn't find an easier way, thouth it's surely possible with Windows API.
I wish to get the function EncodeSprite(), which converts a sprite into an image. For now, when taking a screenshot from a screen (opened with OpenScreen()) I have to grab the sprite and save it on disk, then reload it. This is suboptimal:
Code: Select all
Procedure ScreenToClipBoard()
Protected Sprite,TempImage
Sprite=GrabSprite(#PB_Any,0,0,ScreenWidth(),ScreenHeight())
If Sprite
If SaveSprite(Sprite,GetTemporaryDirectory()+"MyTempImage.bmp",#PB_ImagePlugin_BMP)
TempImage=LoadImage(#PB_Any,GetTemporaryDirectory()+"MyTempImage.bmp",0)
If TempImage
SetClipboardImage(TempImage)
FreeImage(TempImage)
EndIf
DeleteFile(GetTemporaryDirectory()+"MyTempImage.bmp",#PB_FileSystem_Force)
EndIf
FreeSprite(Sprite)
EndIf
EndProcedure