Rev Crash Again! ... cardImage() function

Wouter wouter.abraham at pi.be
Fri Jan 9 07:10:25 EST 2004


On 09 Jan 2004, at 13:00, use-revolution-request at lists.runrev.com wrote:

> Message: 5
> Date: Fri, 9 Jan 2004 00:12:41 -0700
> From: Dar Scott <dsc at swcp.com>
> Subject: Re: Rev Crash Again!  ... cardImage() function
> To: How to use Revolution <use-revolution at lists.runrev.com>
> Message-ID: <367B081A-4273-11D8-8618-000A9567A3E6 at swcp.com>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
>
>
> 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

Here is a little change on that:

#### = changed
function cardImage theStack ####
   local tCurrentCardImage, tOldBuffer, tID
   put the alwaysBuffer of stack theStack into tOldBuffer
   put the cantmodify of stack theStack into tCMOldBuffer  ####
   set the cantmodify of  stack theStack to false   ####
   set the alwaysBuffer of  stack theStack to false
   set the alwaysBuffer of stack theStack to true
   put the windowID of stack theStack into wID
   put the pixMapID of  stack theStack 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 stack 
theStack) ####
     export last image to tCurrentCardImage as PNG
     set the imagePixMapID of last image to tID
     set the alwaysBuffer of stack theStack to false
     set the cantmodify of stack theStack to tCMOldBuffer  ####
     delete last image
   end if
   return tCurrentCardImage
end cardImage


Greetings,

WA



More information about the use-livecode mailing list