Flatten a PICTURE object

Ok… perhaps that isn’t the best description…
I have a number of PNG image files that all contain a mask… I need to convert them to a format (still PNG) but without the mask, and altering the picture level, so that the resultant image still looks IDENTICAL to the original, with one change. Anything that was 100% transparent needs to be replaced with BLUE (&c0000FF)

I have written a program that scans the image and mask using RGBSurface, but cannot determine what to do with any pair of pixels where the mask is other than 100% BLACK or 100% White

If Mask(x,y)=&C121212 and Image(x,y)=&C123456 what color should NEW_IMAGE(x,y) be?

The only thing I know I need is if Mask(x,y)=&CFFFFFF and Image(x,y)=&CFFFFFF then NEW_IMAGE(x,y)=&C0000FF
and I guess if MASK(x,y)=&C00000 then NEW_IMAGE(x,y)=IMAGE(x,y)

and NEW_IMAGE would not have a mask at all

Never Mind :slight_smile:

        old_p=picture.Open(f.trueitem(i))
        new_p=New picture(old_p.width,old_p.height,32)
        Dim gg As graphics
        gg=new_p.Graphics
        gg.forecolor=&c0000ff
        gg.fillrect 0,0,gg.width,gg.height
        gg.drawpicture old_p,0,0
        
        s="output"+Mid(s,6)
        ff=f.TrueItem(i).Parent.child(s)
        new_p.Save(ff,picture.SaveAsPNG)