Hi,
> I'm trying to horizontally mirror an image using copypixels. Might
> this be possible using a reversed destination quad? I imagine so, but
> I'm having some trouble deriving the quad given the rect of the image.
and here you are:
below are two movie script that will return you mirrored images (inputs are
the images you want to flip)... bonus : they also handle alpha channel,
isn't life great? ;?)
on FlipV (startImg) --------------------------------------------------
-- ACTION : return a mirror view od the startImg image, using a
-- horizontal axis
--
-- INPUTS :
-- startImg <#image> : the image to flip
--
-- RETURN : VOID if startImg is not an image
-- <#image> if everything's ok
--------------------------------------------------------------------
-- 1 - check the input
if (ilk(startImg) <> #image) then return VOID
-- 2 - do the rotation
stRect = startImg.rect
topLeft = point(stRect[1], stRect[2])
topRght = point(stRect[3], stRect[2])
botRght = point(stRect[3], stRect[4])
botLeft = point(stRect[1], stRect[4])
destQuad = [botLeft, botRght, topRght, topLeft]
-- flipImg = image(startImg.height, startImg.width, startImg.depth)
-- flipImg.copyPixels(startImg, destQuad, startImg.rect)
if (startImg.depth = 32) then
-- 2.1 bitmap image
flipImg = image(startImg.height, startImg.width, startImg.depth)
flipImg.copyPixels(startImg, destQuad, startImg.rect)
-- 2.2 alpha channel
newAlpha = image(startImg.height, startImg.width, 8, #grayScale)
newAlpha.fill(stRect, rgb(255,255,255))
newAlpha.copyPixels(startImg.extractAlpha(),\
destQuad, startImg.rect,\
[#useFastQuads:FALSE])
-- 2.3 - merge the updated alpha and image
flipImg.setAlpha(newAlpha)
flipImg.useAlpha = TRUE
else
flipImg = image(startImg.height, startImg.width, startImg.depth)
flipImg.copyPixels(startImg, destQuad, startImg.rect)
end if
-- 3 - return the result
return flipImg
end -- FlipV method
on FlipH (startImg) --------------------------------------------------
-- ACTION : return a mirror view of the startImg image, using a
-- horizontal axis
--
-- INPUTS :
-- startImg <#image> : the image to flip
--
-- RETURN : VOID if startImg is not an image
-- <#image> if everything's ok
--------------------------------------------------------------------
-- 1 - check the input
if (ilk(startImg) <> #image) then return VOID
-- 2 - do the rotation
stRect = startImg.rect
topLeft = point(stRect[1], stRect[2])
topRght = point(stRect[3], stRect[2])
botRght = point(stRect[3], stRect[4])
botLeft = point(stRect[1], stRect[4])
destQuad = [topRght, topLeft, botLeft, botRght]
if (startImg.depth = 32) then
-- 2.1 bitmap image
flipImg = image(startImg.height, startImg.width, startImg.depth)
flipImg.copyPixels(startImg, destQuad, startImg.rect)
-- 2.2 alpha channel
newAlpha = image(startImg.height, startImg.width, 8, #grayScale)
newAlpha.fill(stRect, rgb(255,255,255))
newAlpha.copyPixels(startImg.extractAlpha(),\
destQuad, startImg.rect,\
[#useFastQuads:FALSE])
-- 2.3 - merge the updated alpha and image
flipImg.setAlpha(newAlpha)
flipImg.useAlpha = TRUE
else
flipImg = image(startImg.height, startImg.width, startImg.depth)
flipImg.copyPixels(startImg, destQuad, startImg.rect)
end if
-- 3 - return the result
return flipImg
end -- FlipH method
hth,
.seb
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]