The following code creates a JPG file with white background :
B4X:
Dim C As Canvas
Dim Rect1 As Rect
Dim BMPM As Bitmap
BMPM.InitializeMutable(W,H)
C.Initialize2 (BMPM)
Rect1.Initialize(0,0,W-1,H-1)
C.DrawRect(Rect1,Colors.RGB(255,255,255),True,100dip)
Dim Out As OutputStream
Out = File.OpenOutput (File.DirRootExternal , "test.jpg",False )
C.Bitmap.WriteToStream (Out,100,"JPEG")
Out.Close
JPEG doesn't suppost transparency!
You should use PNG.
Instead of C.DrawRect(Rect1, Colors.ARGB(0,255,255,255), True, 100dip)
use C.DrawRect(Rect1, Colors.Transparent, True, 100dip)
I also thought it was impossible...have googled for it
If you are refering to JPEG 2000 (.jp2 or .jpx, but not .jpg or .jpeg) yes it allows transparency, but it "seems" that it is not widely supported (yet?)
With Photoshop in no time you can create an image with transparencies. Possible that you can not do the same with B4A ?
I attach a JPG image created with Photoshop and a PNG with transparent background, just as I want.
I can't see any transparency in your "Transparent.jpg" file --> does it have alpha channel?.
Not sure to understand exactly which is your concern
If you want to create transparent images with B4A in no time --> as Klaus said save them as PNG
B4X:
Dim C As Canvas
Dim Rect1 As Rect
Dim BMPM As Bitmap
BMPM.InitializeMutable(W,H)
C.Initialize2 (BMPM)
Rect1.Initialize(0,0,W-1,H-1)
C.DrawRect(Rect1,Colors.Transparent,True,100dip)
C.DrawText("Happy 2017", 0, 0,Typeface.DEFAULT,20,Colors.Green,"LEFT")
Dim Out As OutputStream
Out = File.OpenOutput (File.DirRootExternal , "test.png",False )
C.Bitmap.WriteToStream (Out,100,"PNG")
Out.Close
After extensive research I concluded that (as I was told in this forum) JPG format does not support transparency !
Evidently with Photoshop you can create pseudo-transparency as I have shown in a picture attached to the post # 7. This led me into error in thinking that it could create JPG images with transparent backgrounds.
Thanks to all of the support