Rev Crash Again! ... cardImage() function

Dar Scott dsc at swcp.com
Fri Jan 9 02:12:41 EST 2004


On Wednesday, January 7, 2004, at 10:00 PM, Dar Scott wrote:

> Here is my function:

Here is a revision that handles the unusual case of the stack in 
defaultFolder not being open or otherwise not containing a valid value.

-- 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, tOldBuffer, tID
   put the alwaysBuffer of this stack into tOldBuffer
   set the alwaysBuffer of this stack to false
   set the alwaysBuffer of this stack to true
   put the windowID of this stack into wID
   put the pixMapID of this stack into pID
   if not ((pID is wID) or (pID is 0)) then
     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 tOldBuffer
     delete last image
   end if
   return tCurrentCardImage
end cardImage

If one tries making a variation of this that is more like imag007, then 
the stack should be checked to be among the lines of openStacks().  If 
this function is used as is to look at other stacks, then care must be 
made in setting the default stack and openStacks() can be checked then, 
too.

In tinkering with this, one might ask whether the temporary image 
should be in the stack getting its portrait or in some utility stack.  
I suspect "create invisible image" will put it on this card, the one 
getting its picture taken.  Is that good or bad?

Dar Scott



More information about the use-livecode mailing list