Android Question image transparent question

park jae hyun

Member
Licensed User
Longtime User
hello
I want to make the image transparent where I want it. Save as a png file.

test1234.jpg

bmp.Initialize(File.DirRootExternal , "testecrop.png")
bmp.InitializeMutable(bmp.Width,bmp.Height)
C1.Initialize2(bmp)
Rect1.Initialize(5,5,50,50)
C1.DrawRect(Rect1, Colors.Transparent, True, 50dip)

Dim Out1 As OutputStream
Out1 = File.OpenOutput (File.DirRootExternal , "testecrop_copy.png",False )
C1.Bitmap.WriteToStream (Out1,70,"PNG")
Out1.Close


After saving, only black screen appears.
Help
 

KZero

Active Member
Licensed User
Longtime User
B4X:
    Dim bmp,bmpMute As Bitmap
    Dim C1 As Canvas
    Dim rect1 As Rect
    bmp.Initialize(File.DirAssets , "testecrop.png") ' the original bitmap
    bmpMute.InitializeMutable(bmp.Width,bmp.Height) 'new mutable bitmap
   
    C1.Initialize2(bmpMute)
    Dim rectBMP As Rect
    rectBMP.Initialize(0,0,bmp.Width,bmp.Height)
    C1.DrawBitmap(bmp,rectBMP,rectBMP) 'to draw the original bitmap to the mutable
    rect1.Initialize(5,5,50,50)
    C1.DrawRect(rect1, Colors.Transparent, True, 50dip)
    Dim Out1 As OutputStream
    Out1 = File.OpenOutput (File.DirRootExternal , "testecrop_copy.png",False )
    C1.Bitmap.WriteToStream (Out1,70,"PNG")
    Out1.Close
 
Last edited:
Upvote 0
Top