Refactoring old pict function

Hi,
I have this old function that change the color of a picture, but it returns a blurred image.
I see that it uses the deprecated “mask” instead of applymask/copymask, but I do not know how to deal with it. Moreover I suspect that scalefactor should be added.

I did a lot of random changings, but with no better results, not to say worst results.
By the way, the pictures involved are all simple, black and white things.

Anybody willing to take a look at it?
(Mac and Windows)
Thanks.

Public Function pictureSetColor(extends origPict as Picture, theColor as Color) As picture
dim pict, mask as Picture

pict = new Picture( origPict.width, origPict.Height, 32 )
mask = new Picture( origPict.width, origPict.Height, 8 )
mask.Graphics.DrawPicture origPict, 0, 0

pict.Graphics.ForeColor = theColor
pict.Graphics.FillRect 0, 0, pict.Width, pict.Height
pict.Mask( true ).Graphics.DrawPicture mask, 0, 0

return pict
End Function

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.