Request: Black&White to Black & Transparent? - RealWorld forums

Log-in or register.

Request: Black&White to Black & Transparent?

Can you make a script that makes white invisible, grey transparent, and so on?
Vector Lightning
on October 20th 2014

I'm looking for a script to make a transparent image from a black-and-white one, that does so by erasing all the white, and replacing the greys with transparent black. This may be possible in other ways that I haven't figured out yet... Is this a scripting problem or is another method better?

on October 20th 2014

yes, script is probably the best way

var image = Document.RasterImage;
var sizeX = image.sizeX;
var sizeY = image.sizeY;
var tmp = Blender.CreateCanvas(sizeX, sizeY, 0);
Blender.Compose(tmp, 0, 0, sizeX, sizeY, image, 0, 0, 0, Blender.OpMapChannels,
    Blender.MapChannels(Blender.ChR, Blender.ChG, Blender.ChB, Blender.ChA,
                        Blender.ChEmpty, Blender.ChEmpty, Blender.ChEmpty, Blender.ChR));
Blender.Compose(tmp, 0, 0, sizeX, sizeY, null, 0, 0, 0xff000000, Blender.OpXor);
Blender.Compose(image, 0, 0, sizeX, sizeY, tmp, 0, 0, 0, Blender.OpSrc);
Vector Lightning
on October 22nd 2014

Perfect! Thank you so much!

You know, maybe a plugin that lets the user (or makes it obvious how to) save scripts would be useful. I've used most of these scripts once or twice...

on October 22nd 2014

Adding new functions in a user-friendly manner would be good, but it needs to be well designed. I'll see what can be done.

Page views: 3193       Posts: 4      
I wish there were...
What about ICL files?
Vista & Win 7 icons