Screen grabber in Alaska
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Screen grabber in Alaska
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?
Re: Screen grabber in Alaska
No, there is not a function. I had to write my own function:
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 oBitmap
The eXpress train is coming - and it has more cars.
-
- Posts: 605
- Joined: Thu Jan 28, 2010 9:11 pm
- Location: Steven Point, Wisconsin USA
- Contact:
Re: Screen grabber in Alaska
There are some additional samples under xbpbitmap in the alaska help file.
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: Screen grabber in Alaska
Hello, everyone!!!
The function apply like this:
oBitmap := GraSaveScreen( oPS, oStatic1:CurrentPos() , oStatic1:CurrentSize() )
oBitmap:SaveFile(cFileName)
Sorry again, black screen. I don't know what to do... While I display charts one by one and do Alt+PrnScreen
The function apply like this:
oBitmap := GraSaveScreen( oPS, oStatic1:CurrentPos() , oStatic1:CurrentSize() )
oBitmap:SaveFile(cFileName)
Sorry again, black screen. I don't know what to do... While I display charts one by one and do Alt+PrnScreen
Re: Screen grabber in Alaska
hm ... what is your oPS ?Eugene Lutsenko wrote: oBitmap := GraSaveScreen( oPS, oStatic1:CurrentPos() , oStatic1:CurrentSize() )
oBitmap:SaveFile(cFileName)
greetings by OHR
Jimmy
Jimmy
-
- Posts: 605
- Joined: Thu Jan 28, 2010 9:11 pm
- Location: Steven Point, Wisconsin USA
- Contact:
Re: Screen grabber in Alaska
This is what I use to capture the current dialog from the screen.
*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± // PC CAW 12-30-05 modified to not do winapi printscreen if object passed
*+
*+ Function LB_Scrn2ClipBoard( oXbp )
*+
*+ Copies the specified object (oXbp) to clipboard or the application
*+ Application desktop if not specified
*+
*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
*+
FUNCTION LB_Scrn2ClipBoard( oXbp )
LOCAL oSourcePS, oBitmap, oClipBoard, aPos
oSourcePS := oXbp:lockPS()
IF oXbp:isDerivedFrom('XbpDialog')
IF left(OS(OS_VERSION),3)>='06.'
aPos := { -8, -8 }
ELSE
aPos := { -4, -4 }
ENDIF
ELSE
aPos := { 0, 0 }
ENDIF
oBitmap := GraSaveScreen( oSourcePS, aPos, oXbp:currentSize() )
RETURN oBitmap
*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± // PC CAW 12-30-05 modified to not do winapi printscreen if object passed
*+
*+ Function LB_Scrn2ClipBoard( oXbp )
*+
*+ Copies the specified object (oXbp) to clipboard or the application
*+ Application desktop if not specified
*+
*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
*+
FUNCTION LB_Scrn2ClipBoard( oXbp )
LOCAL oSourcePS, oBitmap, oClipBoard, aPos
oSourcePS := oXbp:lockPS()
IF oXbp:isDerivedFrom('XbpDialog')
IF left(OS(OS_VERSION),3)>='06.'
aPos := { -8, -8 }
ELSE
aPos := { -4, -4 }
ENDIF
ELSE
aPos := { 0, 0 }
ENDIF
oBitmap := GraSaveScreen( oSourcePS, aPos, oXbp:currentSize() )
RETURN oBitmap
Re: Screen grabber in Alaska
Cliff Wiernik wrote:Code: Select all
oSourcePS := oXbp:lockPS() ... oBitmap := GraSaveScreen( oSourcePS, aPos, oXbp:currentSize() ) // unlock before return oSourcePS:unlockPS() RETURN oBitmap
greetings by OHR
Jimmy
Jimmy
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: Screen grabber in Alaska
Greetings to all!
Tried all suggested options and a few of its own, but is in the form of file is saved in the black screen. And this despite the fact that the screen eyes all is perfectly visible that everything is correct. An error occurred with the line:
GraBitBlt( oTargetPS, oSourcePS, aTargetRect, aSourceRect )
function by Roger:
Tried all suggested options and a few of its own, but is in the form of file is saved in the black screen. And this despite the fact that the screen eyes all is perfectly visible that everything is correct. An error occurred with the line:
GraBitBlt( oTargetPS, oSourcePS, aTargetRect, aSourceRect )
function by Roger:
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
- Attachments
-
- Безымянный.jpg (463.32 KiB) Viewed 17133 times
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: Screen grabber in Alaska
I think I guessed it! In function:
oBitmap := GraSaveScreen( oStatic1, oStatic1:CurrentPos() , oStatic1:CurrentSize() )
after rotation is incorrectly determined position and size. I'll check it
oBitmap := GraSaveScreen( oStatic1, oStatic1:CurrentPos() , oStatic1:CurrentSize() )
after rotation is incorrectly determined position and size. I'll check it
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: Screen grabber in Alaska
Can be anyone who is interested, you can rewrite this program to write two images: 1) before rotating the image; 2) after image rotation:
[/size]
I have failed
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
I have failed