Rotate an image ...
Ben Rubinstein
benr_mc at cogapp.com
Sun Dec 5 18:41:51 EST 2004
on 5/12/04 3:24 pm, Alex Tweedly wrote
> Is there a way to rotate an image to get just the original image, but rotated
> ?
Probably several - this is Rev after all! - but here's a code snippet from
something that works for me:
put the rect of image "KeyImg" into tOldRect
rotate image "KeyImg" by 270
put the rect of image "KeyImg" into tNewRect
if tOldRect <> tNewRect then -- non square, we need to crop
put tNewRect into tLastRect
if (item 1 of tOldRect) = (item 1 of tNewRect) then -- assume Portrait
add (item 2 of tOldRect) - (item 2 of tNewRect) \
to item 1 of tLastRect
subtract (item 4 of tNewRect) - (item 4 of tOldRect) \
from item 3 of tLastRect
else -- assume Landscape
add (item 1 of tOldRect) - (item 1 of tNewRect) \
to item 2 of tLastRect
subtract (item 3 of tNewRect) - (item 3 of tOldRect) \
from item 4 of tLastRect
end if
crop image "KeyImg" to tLastRect
end if
As I say - it works for me. However, for this particular application
incoming images were always the same rectangle, so I won't swear this code
isn't making a dodgy assumption somewhere.
HTH,
Ben Rubinstein | Email: benr_mc at cogapp.com
Cognitive Applications Ltd | Phone: +44 (0)1273-821600
http://www.cogapp.com | Fax : +44 (0)1273-728866
More information about the use-livecode
mailing list