Draw images onto sprites
Posted: Sun Feb 12, 2017 3:43 pm
At the moment it appears that images cant be drawn into sprites, due to some incompatibility. Would be nice if it was possible though.
mh, works for me. Could you post a small snippet to reproduce?MrTAToad wrote:At the moment it appears that images cant be drawn into sprites, due to some incompatibility.
Code: Select all
Global.i spr1,spr2,img
Procedure RenderFrame()
DisplaySprite(spr1,0,0)
DisplaySprite(spr2,128,0)
FlipBuffers()
EndProcedure
InitSprite()
If OpenWindow(0,0,0,640,480,"Pseudo 3D")
If OpenWindowedScreen(WindowID(0),0,0,640,480,0,0,#PB_Screen_NoSynchronization )
spr1=CreateSprite(#PB_Any,32,32,#PB_Sprite_AlphaBlending)
spr2=CreateSprite(#PB_Any,32,32,#PB_Sprite_AlphaBlending)
img=CreateImage(#PB_Any,32,32,32,RGB(0,0,0))
If StartDrawing(ImageOutput(img))
Box(0,0,32,32,RGB(255,0,0))
StopDrawing()
EndIf
If StartDrawing(SpriteOutput(spr1))
Debug "In"
DrawImage(img,0,0)
Debug "Out"
StopDrawing()
Else
EndIf
If StartDrawing(SpriteOutput(spr2))
Box(0,0,32,32,RGB(255,255,0))
StopDrawing()
EndIf
BindEvent(#PB_Event_RenderFrame,@RenderFrame())
FlipBuffers()
EndIf
EndIf
The reason for wanting this is as there are no polygon commands yet, I might use Vector Drawing. But that can only be onto a canvas or image. A canvas is out of the question, so it has to be an image which would then be displayed by a sprite.TypeError: Argument 1 of CanvasRenderingContext2D.drawImage could not be converted to any of: HTMLImageElement, HTMLCanvasElement, HTMLVideoElement, ImageBitmap.
Code: Select all
[...]
DrawImage(ImageID(img),0,0)
[...]