How to save a part of canvas as image file?

ozgureffe

Member
Licensed User
Longtime User
Is it possible to save some part of canvas as new image file.

Or do I have to save whole image first than crop that part with Drawbitmap method?
 

ozgureffe

Member
Licensed User
Longtime User
So where am I wrong?

B4X:
Sub nextPanel_Click
    Dim Out As OutputStream

[COLOR=DarkRed]    [B]bmp_note[/B].Initialize3(cnvs_note.Bitmap)[/COLOR]
    
    fileNameFull = panelNum & ".PNG"
    Out = File.OpenOutput(File.DirRootExternal & "/temp",[B]fileNameFull[/B], False)
    [B]bmp_note[/B].WriteToStream(out, 100, "PNG")
    Out.Close

[COLOR=DarkRed]   [B] bmp_NotePart[/B].InitializeMutable(300,300)
    cnvs_note.Initialize2(bmp_NotePart)[/COLOR]
    
    FileNamePart = panelNum & "_p.PNG"    
    Out = File.OpenOutput(File.DirRootExternal & "/temp",[B]fileNamePart[/B], False)
    [B]bmp_NotePart[/B].WriteToStream(out, 100, "PNG")
    Out.Close
    
    cnvs_note.Initialize(pnl_notePanel)
End Sub
I am getting only a blank image as "fileNamePart" file instead of cropped part of my image despite my canvas is not.

Thank you.
 
Last edited:
Upvote 0
Top