Rev Crash Again! ... cardImage() function

Dar Scott dsc at swcp.com
Thu Jan 8 00:00:37 EST 2004


On Wednesday, January 7, 2004, at 07:37 PM, Jim Carwardine wrote:

> No, I'm back to rev crashing every second time.  I don't think I 
> clearly
> understood Dar's fix... Jim

OK.  OK.  Quit twisting my arm.  Here is my function:

--
-- cardImage()
-- by Dar Scott
-- Returns an image (PNG) of current card even if obscured
-- or off screen.  In addition this works when
-- lock screen is on, allowing PNGs of other cards to be obtained.
-- This is based on code by Ken Ray and Brian Yennie.
function cardImage
   local tCurrentCardImage, tOldAlwaysBuffer, tID
   put the alwaysBuffer of this stack into tOldAlwaysBuffer
   set the alwaysBuffer of this stack to false
   set the alwaysBuffer of this stack to true
   create invisible image
   put the imagePixMapID of last image into tID
   set the imagePixMapID of last image to (the pixMapID of this stack)
   export last image to tCurrentCardImage as PNG
   set the imagePixMapID of last image to tID
   set the alwaysBuffer of this stack to tOldAlwaysBuffer
   delete last image
   return tCurrentCardImage
end cardImage

This works for me in getting the image of the current card.  I have a 
button that gets the image of another card in the stack and that seems 
to work, too.  It uses this function.  Because of a bug, I export to 
get the PNG image; getting the text is not reliable.  It might be I 
don't know why this works.  I'm on OS X 10.2.8 and I use Revolution 
2.1.2.

I have a stack-thumbnail plugin and a special special-effects library 
on the back burner that I hoped to use this in.  (I also have dreamed 
of a 3-D stack explorer, but that is probably not practical.)  I think 
there might be lots of uses for such a thing.  My having a project on 
the back burner should not stop anybody from doing something similar; I 
have lots on the back burner.

I got the idea of this from tip imag007 at Ken Ray's site:
http://www.sonsothunder.com/devres/metacard/tips/imag007.htm

This takes about 50 ms on my computer.  Dual 1.25 GHz G4.

Use this like this:
put cardImage() into field "thumbnail"

I'd be pleased to hear how this works.  Or doesn't work.

Dar

****************************************
     Dar Scott Consulting
     http://www.swcp.com/dsc/
     Programming Services
****************************************



More information about the use-livecode mailing list