GMImageMBS transparent

  1. 6 days ago

    Jeff T

    Nov 13 Midlands of England, Europe

    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?

    I think I cracked it.
    The undocumented(?) compositeoperator - MBS docs say it defaults to 2
    Switching it to 1 seems to have sorted it.

    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

  2. 5 days ago

    Christian S

    Nov 14 Pre-Release Testers, Xojo Pro Germany

    You can make a new white GMImageMBS and composite the PNG GMImageMBS on top of that.

  3. Jeff T

    Nov 14 Midlands of England, Europe

    Ive tried this, but same result:

       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
  4. Jeff T

    Nov 14 Answer Midlands of England, Europe

    I think I cracked it.
    The undocumented(?) compositeoperator - MBS docs say it defaults to 2
    Switching it to 1 seems to have sorted it.

    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

  5. Christian S

    Nov 14 Pre-Release Testers, Xojo Pro Germany

    this is my solution:

    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
  6. Christian S

    Nov 14 Pre-Release Testers, Xojo Pro Germany

    Well, default operation is 2 (InCompositeOp), but you need here 1 (OverCompositeOp).

or Sign Up to reply!