Screen grabber in Alaska
Posted: Wed Jul 19, 2017 1:39 am
				
				Is there in Alaska a function or program that provides a Screen grabber is the active window and allows to save the image as a file?
			Donnay Software Web Forums
http://donnay-software.com/DONNAY/
Code: Select all
FUNCTION GraSaveScreen( oSourcePS, aPos, aSize )
LOCAL oBitmap   := XbpBitmap():new():create( oSourcePS )
LOCAL oTargetPS := XbpPresSpace():new():create()
LOCAL aSourceRect[4], aTargetRect
aSourceRect[1] := aSourceRect[3] := aPos[1]
aSourceRect[2] := aSourceRect[4] := aPos[2]
aSourceRect[3] += aSize[1]
aSourceRect[4] += aSize[2]
aTargetRect    := {0, 0, aSize[1], aSize[2]}
oBitmap:presSpace( oTargetPS )
oBitmap:make( aSize[1], aSize[2] )
GraBitBlt( oTargetPS, oSourcePS, aTargetRect, aSourceRect )
RETURN oBitmaphm ... what is your oPS ?Eugene Lutsenko wrote: oBitmap := GraSaveScreen( oPS, oStatic1:CurrentPos() , oStatic1:CurrentSize() )
oBitmap:SaveFile(cFileName)
Cliff Wiernik wrote:Code: Select all
oSourcePS := oXbp:lockPS() ... oBitmap := GraSaveScreen( oSourcePS, aPos, oXbp:currentSize() ) // unlock before return oSourcePS:unlockPS() RETURN oBitmap
Code: Select all
*************************************************
******** Сохранение экрана (Screen grabber) Roger
*************************************************
FUNCTION GraSaveScreen( oSourcePS, aPos, aSize )
LOCAL oBitmap   := XbpBitmap():new():create( oSourcePS )
LOCAL oTargetPS := XbpPresSpace():new():create()
LOCAL aSourceRect[4], aTargetRect
aSourceRect[1] := aSourceRect[3] := aPos[1]
aSourceRect[2] := aSourceRect[4] := aPos[2]
aSourceRect[3] += aSize[1]
aSourceRect[4] += aSize[2]
aTargetRect    := {0, 0, aSize[1], aSize[2]}
oBitmap:presSpace( oTargetPS )
oBitmap:make( aSize[1], aSize[2] )
GraBitBlt( oTargetPS, oSourcePS, aTargetRect, aSourceRect )
RETURN oBitmap
Code: Select all
//////////////////////////////////////////////////////////////////////
//
//  FANCYFNT.PRG
//
//  Copyright:
//      Alaska Software, (c) 1997-2009. All rights reserved.         
//  
//  Contents:
//      This sample program renders some text strings demonstrating the GRA
//      engine's GraStringAt() primitive.
//   
//////////////////////////////////////////////////////////////////////
#include "appevent.ch"
#include "xbp.ch"
#include "gra.ch"
******************************************************************************
* Main() procedure and event loop
******************************************************************************
PROCEDURE Main
   LOCAL nEvent, mp1, mp2, oObj
   LOCAL oPS
   LOCAL oFont
   LOCAL aLineAttrs
   LOCAL aStringAttrs
   LOCAL aMatrix
   LOCAL i
   /*
    * Setup XbpCrt object created by the AppSys()
    * procedure
    */
   SetAppWindow():useShortCuts := .T.
   SetColor( "N/W+" )
   CLS
   /* Get presentation space for rendering   */
   oPS := SetAppWindow():presSpace()
   oFont := XbpFont():new():create("20.Arial Bold")
   GraSetFont(oPS , oFont)
   aAttrF := ARRAY( GRA_AS_COUNT ) 
   aAttrF [ GRA_AS_COLOR      ] := GRA_CLR_BLACK 
   aAttrF [ GRA_AS_HORIZALIGN ] := GRA_HALIGN_LEFT
   aAttrF [ GRA_AS_VERTALIGN  ] := GRA_VALIGN_HALF
   GraSetAttrString( oPS, aAttrF ) 
   GraStringAt( oPS, { 20,350 }, 'The text before the rotation' )
   *********************************************
   ******** Save before rotating the image *****
   *********************************************
   /*
    * Rotate text strings to show transforms via
    * SetGraTransform()
    */
   oFont := XbpFont():new():create("10.Arial Bold")
   GraSetFont(oPS , oFont)
   aAttrF := ARRAY( GRA_AS_COUNT ) 
   aAttrF [ GRA_AS_COLOR      ] := GRA_CLR_BLACK 
   aAttrF [ GRA_AS_HORIZALIGN ] := GRA_HALIGN_CENTER
   aAttrF [ GRA_AS_VERTALIGN  ] := GRA_VALIGN_HALF
   GraSetAttrString( oPS, aAttrF ) 
   nAngle = 10
   aMatrix := GraInitMatrix()
   FOR i:=1 TO nAngle
      GraRotate( oPS, aMatrix, 360/nAngle, {200, 200}, GRA_TRANSFORM_ADD )
      oPS:setGraTransform( aMatrix, GRA_TRANSFORM_REPLACE )
      GraStringAt( oPS, {100,100}, ALLTRIM(STR(i))+"-Rotated text..." )
   NEXT
   ***** Rotate the image (360) for proper rendering
   GraRotate( oPS, aMatrix, 360, {200, 200}, GRA_TRANSFORM_ADD )
   oPS:setGraTransform( aMatrix, GRA_TRANSFORM_REPLACE )
   
   oFont := XbpFont():new():create("20.Arial Bold")
   GraSetFont(oPS , oFont)                        
   aAttrF := ARRAY( GRA_AS_COUNT ) 
   aAttrF [ GRA_AS_COLOR      ] := GRA_CLR_BLACK 
   aAttrF [ GRA_AS_HORIZALIGN ] := GRA_HALIGN_LEFT
   aAttrF [ GRA_AS_VERTALIGN  ] := GRA_VALIGN_HALF
   GraSetAttrString( oPS, aAttrF ) 
   GraStringAt( oPS, { 20,50 }, 'The text after the label at an angle' )
   *********************************************
   **** Save after image rotation **************
   *********************************************
   INKEY(0)
RETURN
// EOF