Image Processing Makes Livecode Appear to Crash
Ray
ray at linkit.com
Mon Feb 17 13:24:38 EST 2014
Fellow LC Users,
I'm trying to provide users with a 'magic wand' style tool. Click an
image, pick up the color clicked and turn every pixel of that same color
in the image transparent.
The loop I've written takes about 30 seconds to run on a 600 by 700
pixel image, which is a problem, but worse, click anywhere before it's
finished and Livecode 'appears' to crash. I say 'appears' because the
cursor turns into the crash cursor and the title bar displays 'not
responding'. After the loop is done Livecode returns to normal.
I'll include the loop, below.
How do I stop LC from appearing to crash while running this loop, or how
to speed it up.
Thanks,
Ray
LinkIt! Software
on mouseUp
lock messages
put the mousecolor into myColor
put the mouseloc into myLoc
put the imagedata of img 1 into totColorData
put the alphadata of img 1 into totAlphaData
put numToChar(item 1 of myColor) into binColor
put numToChar(item 2 of myColor) after binColor
put numToChar(item 3 of myColor) after binColor
put numtochar(0) into bin0 -- transparency
repeat for each char curBin in totAlphaData
if char 2 to 4 of totColorData = binColor then
put bin0 after newAlphaData
else put curBin after newAlphaData
delete char 1 to 4 of totColorData
set the cursor to busy
end repeat
set the alphadata of img 1 to newAlphaData
end mouseUp
More information about the use-livecode
mailing list