When opening a PNG image with transparent pixels using Xojo, the transparent parts are white.
When doing the same with GMImageMBS , they are black.
I believe I could avoid this by setting the BackGroundColor to white, but that has made no effect
Online, I found some help that suggests calling .flatten on the image, but that call doesnt appear to available in GMImageMBS
How to make transparent pixels white?
You can make a new white GMImageMBS and composite the PNG GMImageMBS on top of that.
Ive tried this, but same result:
[code] dim g_original as new GMImageMBS(f)
dim geo as new GMGeometryMBS(g_original.width,g_original.height)
dim c as new GMColorRGBMBS(1.0,1.0,1.0) // white
dim g as new GMImageMBS(g, c) ///should have a white image now
g.composite g_original,geo, 2 // composite ..same result[/code]
I think I cracked it.
The undocumented(?) compositeoperator - MBS docs say it defaults to 2
Switching it to 1 seems to have sorted it.
[code]dim g_original as new GMImageMBS(f)
dim geo as new GMGeometryMBS(g_original.width,g_original.height)
dim c as new GMColorRGBMBS(1.0,1.0,1.0) // white
dim g as new GMImageMBS(g, c) ///should have a white image now
g.composite g_original,geo, 1 [/code]
this is my solution:
[code]dim f as FolderItem = SpecialFolder.Desktop.Child(“test.png”)
dim InputImage as new GMImageMBS(f)
dim geo as new GMGeometryMBS(InputImage.width, InputImage.height)
dim white as new GMColorRGBMBS(1.0,1.0,1.0) // white
dim OutputImage as new GMImageMBS(geo, white) ///should have a white image now
OutputImage.composite InputImage, geo, GMImageMBS.OverCompositeOp // composite …same result
Backdrop = OutputImage.CopyPicture[/code]
Well, default operation is 2 (InCompositeOp), but you need here 1 (OverCompositeOp).