Hello,
Win 10, [PB5.73 x64]
I need to copy a sprite to an image,
I found CopySprite (Sprite1, Sprite2)
But what is the best way to copy sprite to an image ?
I like to make a procedure CopySpriteToImage (Sprite#, Image#)
Thanks,
Marc
copy a sprite to an image ...
copy a sprite to an image ...
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
PS: sorry for my english I speak flemish ...
Re: copy a sprite to an image ...
SpriteOutput() + GrabDrawingImage()
Re: copy a sprite to an image ...
Code: Select all
Procedure.i CopySpriteToImage(Sprite.i, Image.i)
Protected Result.i
If IsSprite(Sprite)
If StartDrawing(SpriteOutput(Sprite))
Result = GrabDrawingImage(Image, 0, 0, SpriteWidth(Sprite), SpriteHeight(Sprite))
StopDrawing()
EndIf
EndIf
ProcedureReturn Result
EndProcedure
Re: copy a sprite to an image ...
Quick hack
SubSystem Directx9
Nothing new from Fred and infratec but I am sure it works
SubSystem Directx9
Nothing new from Fred and infratec but I am sure it works

Code: Select all
If InitSprite() = 0 Or InitKeyboard() = 0
MessageRequester("Error", "Sprite system can't be initialized", 0)
End
EndIf
Procedure Sprite2Image(sprite,img)
If IsSprite(sprite)
StartDrawing(SpriteOutput(sprite))
DrawingMode(#PB_2DDrawing_AllChannels )
GrabDrawingImage(img,0,0,SpriteWidth(0),SpriteHeight(0))
StopDrawing()
SaveImage(img,GetTemporaryDirectory()+"test.bmp")
Else
End
EndIf
EndProcedure
If OpenScreen(800, 600, 32, "Sprite")
; Load our 16 bit sprite (which is a 24 bit picture in fact, as BMP doesn't support 16 bit format)
;
LoadSprite(0, #PB_Compiler_Home + "examples/sources/Data/PureBasic.bmp",#PB_Sprite_AlphaBlending)
Sprite2Image(0,0)
Else
MessageRequester("Error", "Can't open a 800*600 - 32 bit screen !", 0)
EndIf
Egypt my love
Re: copy a sprite to an image ...
Hi,
thanks guys for the tips,
But stupid me ...
I wrote an image rotation procedure
but the result of the rotated pixels was not so good ...
So, I wanted to use the RotateStrite to rotate the sprite and copy this to an Image,
but didn't work with SpriteOutput() + GrabDrawingImage()
The Sprite is only rotated on the screen and not in the memory ...
What I did now is to :
- Draw all on the Sprite
- Rotate Sprite
- Draw Sprite on the Screen
- and use GrabSprite ()
With SpriteQuality () the result is not 100%, but I can life with it
Thanks,
Marc
thanks guys for the tips,
But stupid me ...
I wrote an image rotation procedure
but the result of the rotated pixels was not so good ...
So, I wanted to use the RotateStrite to rotate the sprite and copy this to an Image,
but didn't work with SpriteOutput() + GrabDrawingImage()
The Sprite is only rotated on the screen and not in the memory ...


What I did now is to :
- Draw all on the Sprite
- Rotate Sprite
- Draw Sprite on the Screen
- and use GrabSprite ()
With SpriteQuality () the result is not 100%, but I can life with it

Thanks,
Marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
PS: sorry for my english I speak flemish ...