Turning imageData into alphaData (quickly)?

Ian Wood revlist at azurevision.co.uk
Mon Mar 13 05:46:25 EST 2006


Hi all, I've been lurking for a few years, but not posted for some  
time...

I'm doing quite a lot of stuff generating PNGs with transparency, and  
wondered if there is any fast way to combine an 'image' img and a  
'transparency' img?
A handler that goes through each RGB pixel and reduce it to a  
grayscale value for use as alphaData was pretty easy, but for a  
200x200px image that's 40,000 repeats, and takes minutes on a G5.

on maskStuff
   put the seconds into tStart
   put "" into tMaskData
   put the imageData of img "mask" into tImgData
   put number of chars of tImgData / 4 & return into fld "status"
   lock screen
   repeat with x = 1 to ((number of chars of tImgData) / 4)
     if the mouse is down then exit to top
     put charToNum(char (x*4)-2 of tImgData) into tR
     put charToNum(char (x*4)-1 of tImgData) into tG
     put charToNum(char (x*4) of tImgData) into tB
     put the round of ((tR + tG + tB)/3) into tM
     put numToChar(tM) after tMaskData
     --put tM & return after fld "status"
   end repeat
   unlock screen
   put the seconds - tStart after fld "status"
end maskStuff

As the project is currently on a Mac I can use AppleScripts to do it  
all in Photoshop from two exported images (and makes it easy to add  
drop-shadows), but for future cross-platform use this is a no-no.

Any ideas for a faster way? Cross-platform command-line tools?

Ian Wood
Panoramic photography, from web to billboard, sunrise to moonrise
http://www.landmarksofbritain.co.uk
http://www.azurevision.co.uk


P.S. OS X 10.4.5, Rev 2.7 (haven't gone back and tried in 2.6 yet).



More information about the Use-livecode mailing list