picture.ReplaceColorMBS loses transparency

As per the title.
With a png that has transparent areas, if I change green to red, the transparent areas are rendered opaque

if I use a loop on the rgbsurface and swap green to red, it is retained, but obviously slower.
Is there a setting I missed (it only has two parameters) or a better way to do this?

Sorry, this function was not written with transparency in mind.

Maybe you better loop over pixels with RGBSurface and change pixels there.


It appears there is also no similar functionality in GraphicsMagick
I have 40 x 64 pixel square images to process.
Thats 163 thousand calls to .pixel

It works, but …

I can turn the picture into a memoryblock with

dim m as MemoryBlock = GetMBfromPictureMBS(p, "ARGB32")

So assuming inside that memory block there are some values like &cAABBCC00
and I wish to swap them to be &cBBAACC00
is there a one liner that does search and replace of 32bit integers in a memory block, after which I turn the block back into a picture?

If you do that with a ptr and a loop with background tasks off, the LLVM compiler can optimize it a bit.

Having timed it, each image takes 1 tick or less using RGBSurface
I can live with that

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