Fastest way to make color transparent?

from “the other forum”

Why not take the original picture
use RGBSURFACE TRANSFORM to change all non-white pixels to black
then apply THAT picture as the mask to the first picture?

Not fractional seconds, but faster that looking at each pixel one by one


replied to @ubogun here
he reads this as well :slight_smile:
but yeah taking the original picture, transforming the desired color to white pixels and all the rest to black then using that as a mask should work pretty quickly

I hate the way transform works :stuck_out_tongue:

If you supply one map then every color that has any component that matches one index will get mapped to something else
If you supply 3 then any color that has any one of those gets mapped

Assume ALL entries map as map(i) = i except as noted

If you supply a single map with map(128) = 0
Then any pixel that has RGB = (128, 128, 128) would get mapped to (0,0,0)
But a RGB of (128, 245, 245) would turn into (0,245,245)

With 3 maps its not much different just that instead of the RGB values being mapped to the same value you could specify several
If you supply maps with redmap(128) = 0, greenmap(128) = 250, bluemap(128) = 30
Then any pixel that has RGB = (128, 128, 128) would get mapped to (0,250,30)
But a RGB of (128, 245, 245) would turn into (0,245,245)
And one of RGB( 245, 128, 245) would turn into (245, 250, 245)

Theres no map that looks up ALL components as ONE key and transforms those to some other single color

Transform seems to need a set up like :

   dim map() as Dictionary
   map.value( fromColor ) = toColor
   Tranform( map )

and then pixels that match the KEY color would transform to the other color and NOTHING else would be altered

its been a while since I’ve used this…
but wouldnt it be something like

for i=0 to 254

but if you were looking to change a specific color (not-white) then yeah its more difficult

Thanks for still discussing this!
The transform idea looks promising, but as you may have read I as reminded by Karen on a method I used to use myself for this case but forgot in between. So, as long as the old picture type exists, copying over to an old picture with transparent = 1 is fast enough for me. Possibly not THE fastest method, but good enough.