Code: Select all
Procedure.s CanvasToImageURL(gadget, plugin)
thingy = GadgetID(gadget)
imagedata.s = ""
If plugin = #PB_ImagePlugin_PNG
!v_imagedata = v_thingy.canvas.toDataURL("image/png")
ElseIf plugin = #PB_ImagePlugin_JPEG
!v_imagedata = v_thingy.canvas.toDataURL("image/jpeg")
EndIf
ProcedureReturn imagedata
EndProcedure
This could probably be modified to use Images instead (maybe by creating an invisible canvas and transferring the image), but this was sufficient for my purposes. I thought that someone might find it useful.
It takes the gadget as the first argument and the second is the #PB_ImagePlugin_* although BMP doesn't seem to be supported as an export format.
Apologies if this has already been done. Although if there is a built in method that I don't know about, please let me know.