Image Remove Perimeter White Space
Ralph DiMola
rdimola at evergreeninfo.net
Wed Dec 26 22:35:30 EST 2018
Thanks!
I'll give it a try in the am. All of the images are 512/512 or less(icons).
Ralph DiMola
IT Director
Evergreen Information Services
rdimola at evergreeninfo.net
Phone: 518-636-3998 Ex:11
Cell: 518-796-9332
-----Original Message-----
From: use-livecode [mailto:use-livecode-bounces at lists.runrev.com] On Behalf
Of hh via use-livecode
Sent: Wednesday, December 26, 2018 7:58 PM
To: use-livecode at lists.runrev.com
Cc: hh
Subject: Re: Image Remove Perimeter White Space
Here is a pure LC Script handler from one of my "early" images stacks.
For large images this may become pretty slow...
## CROP image to opaque pixels
on cropIt ft
put the width of img ft into w; put the height of img ft into h
put the maskdata of img ft into mData
put numToByte(0) into c0
-- left and right transparency limits
put w into cmin; put 1 into cmax
repeat with i=0 to h-1
put i*w into h1
repeat with j=1 to cmin
if byte h1+j of mData is not c0 then
put j into cmin; exit repeat
end if
end repeat
repeat with j=w down to max(cmax,cmin)
if byte h1+j of mData is not c0 then
put j into cmax; exit repeat
end if
end repeat
end repeat
put max(1,cmin-2) into cmin; put min(w,2+cmax) into cmax ## <- +border
-- top and bottom transparency limits
put h into rmin; put 1 into rmax
repeat with j=cmin to cmax
repeat with i=0 to rmin-1
if byte i*w+j of mData is not c0 then
put i into rmin; exit repeat
end if
end repeat
repeat with i=h-1 down to max(rmax,rmin)
if byte i*w+j of mData is not c0 then
put i into rmax; exit repeat
end if
end repeat
end repeat
put max(1,rmin-2) into rmin; put min(h,2+rmax) into rmax ## <- +border
put (cmax-cmin+1) into w1; put (rmax-rmin) into h1
put the left of img ft into L; put the top of img ft into T
crop img ft to L+cmin-1,T+rmin,L+cmax,T+rmax
-- LC Bug: resizes instead of cropping when image has angle <> 0 end
cropIt
_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list