Screenshot

806 views
Skip to first unread message

Giovanni Di Maria

unread,
Sep 8, 2020, 5:31:53 AM9/8/20
to Harbour Users

Hi everyone
Is there a function to take a graphic desktop screenshot and save it as JPG or PNG?
Thank you all.

Giovanni Di Maria

Maurizio la Cecilia

unread,
Sep 8, 2020, 7:16:54 AM9/8/20
to Harbour User Group
Hi Giovanni,
do you need just for Windows or also for Linux?

--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/f0617a6a-c46e-4ed2-9dc0-1d1e41210957n%40googlegroups.com.

Giovanni Di Maria

unread,
Sep 8, 2020, 7:58:51 AM9/8/20
to Harbour Users
Hi Maurizio.
For Windows (but in future perhaps for Linux).
Thank you
Giovanni

Luigi Ferraris

unread,
Sep 8, 2020, 11:22:12 AM9/8/20
to Harbour Users
Hi Giovanni,
on Windows (from XP) I'm using Gadwin PrintScreen; there are free and pro (to pay) versions from here GadwinPrintscreen
You can play with settings.
Regards
Luigi Ferraris

amnaples

unread,
Sep 8, 2020, 11:49:07 AM9/8/20
to Harbour Users
I use ScreenShotMaker in Minigui\SAMPLES\Applications\ScreenShotMaker
Rgds
Arcangelo

Alain Aupeix

unread,
Sep 8, 2020, 1:17:46 PM9/8/20
to harbou...@googlegroups.com, Luigi Ferraris
Le 08/09/2020 à 17:22, Luigi Ferraris a écrit :
Hi Giovanni,
on Windows (from XP) I'm using Gadwin PrintScreen; there are free and pro (to pay) versions from here GadwinPrintscreen
For Linux, shutter is the best !!!

A+
--

Alain Aupeix
Sites web : JujuLand | Pissobi-Lacassagne | Gadel
X.ubuntu 16.04 [ H.arbour 3.2.0dev (r2020-08-19 00:02) | Hw.gui 2.22-4 (r2876) | G.ramps 5.1.2


Giovanni Di Maria

unread,
Sep 8, 2020, 2:50:38 PM9/8/20
to Harbour Users

Ok.
Thank you to all.
Giovanni
 

Auge & Ohr

unread,
Sep 8, 2020, 8:00:01 PM9/8/20
to Harbour Users
hi,

under HMG you can "RegisterHotKey" VK_SNAPSHOT and use BosTaurus Function.
when press "print Screen" it will grab Event and redirect to DO_SnapShot()

p.s. you can also call DO_SnapShot() direct from your Code


   HMG_CallDLL
("User32.DLL", DLL_OSAPI, "RegisterHotKey", Form_1.HANDLE, 1, 0, VK_SNAPSHOT)
   CREATE EVENT PROCNAME
PrtScr_Detect() HWND Form_1.HANDLE STOREINDEX nIndex
   
EventProcessAllHookMessage( nIndex, .T. )

FUNCTION PrtScr_Detect()
LOCAL nHWnd  
:= EventHWND()
LOCAL nMsg    
:= EventMSG()
LOCAL nWParam
:= EventWPARAM()
LOCAL nLParam
:= EventLPARAM()
   DO CASE
      CASE nMsg
== WM_HOTKEY
         DO_SnapShot
()
   ENDCASE
RETURN NIL

PROCEDURE DO_SnapShot()
LOCAL
Width        := BT_DesktopWidth()
LOCAL
Height       := BT_DesktopHeight()
LOCAL
Row          := 0
LOCAL
Col          := 0
LOCAL nTypePicture
:= BT_FILEFORMAT_JPG
LOCAL cUser        
:= GETENV( "USERPROFILE" )
LOCAL hBitmap
LOCAL cFileName

   
//  %USERPROFILE%\Pictures\Screenshots
   cFileName
:= cUser + "\Pictures\Err" + DTOS( DATE() ) + STRZERO( SECONDS(), 5 ) + ".JPG"

   hBitmap
:= BT_BitmapCaptureDesktop( Row, Col, Width, Height )
   
// BT_BitmapCaptureWindow (Win, Row, Col, Width, Height)
   
// BT_BitmapCaptureClientArea (Win, Row, Col, Width, Height)
   BT_BitmapSaveFile
( hBitmap, cFileName, nTypePicture )

   
// here you can send email with Attachment

   
// don'nt forget to put Bitmap to Clipboard
   BT_BitmapClipboardPut
( Form_1.HANDLE, hBitmap )
   FERASE
( cFileName )

RETURN

Maurizio la Cecilia

unread,
Sep 9, 2020, 3:19:12 AM9/9/20
to harbou...@googlegroups.com
--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/f0617a6a-c46e-4ed2-9dc0-1d1e41210957n%40googlegroups.com.

Hi Giovanni, below my function derived by some contributions found on the web.

The major limitation is that the output file is a bitmap, thus I introduced a parameter to limit the size of the saved file.

I'm calling it using:

hbs_ScreenShotHb_GtInfo( HB_GTI_WINHANDLE ), <cBmpFileName>, [ <nWidthInPixelOutput> (default to 300)] )

hbs_screenshot.c
#include <windows.h>
#include <wingdi.h>
#include "hbapi.h"
#include <ole2.h>
#include <olectl.h>
HB_FUNC( HBS_SCREENSHOT )
{
    HWND hWnd = (HWND) hb_parptr1 );
    LPCSTR fname = hb_parc2 );
    int maxWidth = hb_parnidef3800 );
    int bmpWidth;
    int bmpHeight;
    HDC hdcScreen;
    HDC hdcWindow;
    HDC hdcMemDC = NULL;
    HBITMAP hbmScreen = NULL;
    BITMAP bmpScreen;
    // Retrieve the handle to a display device context for the client
    // area of the window.
    hdcScreen = GetDC(NULL);
    hdcWindow = GetWindowDC(hWnd);
    // Create a compatible DC which is used in a BitBlt from the window DC
    hdcMemDC = CreateCompatibleDC(hdcWindow);
    // Get the client area for size calculation
    RECT rcClient;
    GetWindowRect(hWnd, &rcClient);
    bmpWidth = rcClient.right - rcClient.left ;
    bmpHeight = rcClient.bottom - rcClient.top ;
    if ( bmpWidth > maxWidth )
        {
        bmpHeight = bmpHeight * maxWidth / bmpWidth ;
        bmpWidth  = maxWidth ;
        }
    //This is the best stretch mode
    SetStretchBltMode(hdcWindow,HALFTONE);
    StretchBlt(hdcWindow,
               0,0,
               bmpWidth, bmpHeight,
               hdcScreen,
               rcClient.leftrcClient.top,
               rcClient.right - rcClient.left,
               rcClient.bottom - rcClient.top,
               SRCCOPY);
    // Create a compatible bitmap from the Window DC
    hbmScreen = CreateCompatibleBitmap(hdcWindow, bmpWidth, bmpHeight);
    // Select the compatible bitmap into the compatible memory DC.
    SelectObject(hdcMemDC,hbmScreen);
    // Bit block transfer into our compatible memory DC.
    BitBlt(hdcMemDC,
               0,0,
               bmpWidth, bmpHeight,
               hdcWindow,
               0,0,
               SRCCOPY);
    // Get the BITMAP from the HBITMAP
    GetObject(hbmScreen,sizeof(BITMAP),&bmpScreen);
    BITMAPFILEHEADER   bmfHeader;
    BITMAPINFOHEADER   bi;
    bi.biSize = sizeof(BITMAPINFOHEADER);
    bi.biWidth = bmpScreen.bmWidth;
    bi.biHeight = bmpScreen.bmHeight;
    bi.biPlanes = 1;
    bi.biBitCount = 32;
    bi.biCompression = BI_RGB;
    bi.biSizeImage = 0;
    bi.biXPelsPerMeter = 0;
    bi.biYPelsPerMeter = 0;
    bi.biClrUsed = 0;
    bi.biClrImportant = 0;
    DWORD dwBmpSize = ((bmpScreen.bmWidth * bi.biBitCount + 31) / 32) * 4 * bmpScreen.bmHeight;
    // Starting with 32-bit Windows, GlobalAlloc and LocalAlloc are implemented as wrapper functions that
    // call HeapAlloc using a handle to the process's default heap. Therefore, GlobalAlloc and LocalAlloc
    // have greater overhead than HeapAlloc.
    HANDLE hDIB = GlobalAlloc(GHND,dwBmpSize);
    char *lpbitmap = (char *)GlobalLock(hDIB);
    // Gets the "bits" from the bitmap and copies them into a buffer
    // which is pointed to by lpbitmap.
    GetDIBits(hdcWindow, hbmScreen, 0,
        (UINT)bmpScreen.bmHeight,
        lpbitmap,
        (BITMAPINFO *)&bi, DIB_RGB_COLORS);
    // A file is created, this is where we will save the screen capture.
    HANDLE hFile = CreateFile( fname,
        GENERIC_WRITE,
        0,
        NULL,
        CREATE_ALWAYS,
        FILE_ATTRIBUTE_NORMAL, NULL);
    // Add the size of the headers to the size of the bitmap to get the total file size
    DWORD dwSizeofDIB = dwBmpSize + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
    //Offset to where the actual bitmap bits start.
    bmfHeader.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + (DWORD)sizeof(BITMAPINFOHEADER);
    //Size of the file
    bmfHeader.bfSize = dwSizeofDIB;
    //bfType must always be BM for Bitmaps
    bmfHeader.bfType = 0x4D42//BM
    DWORD dwBytesWritten = 0;
    WriteFile(hFile, (LPSTR)&bmfHeader, sizeof(BITMAPFILEHEADER), &dwBytesWritten, NULL);
    WriteFile(hFile, (LPSTR)&bi, sizeof(BITMAPINFOHEADER), &dwBytesWritten, NULL);
    WriteFile(hFile, (LPSTR)lpbitmap, dwBmpSize, &dwBytesWritten, NULL);
    //Unlock and Free the DIB from the heap
    GlobalUnlock(hDIB);
    GlobalFree(hDIB);
    //Close the handle for the file that was created
    CloseHandle(hFile);
    //Clean up
    DeleteObject(hbmScreen);
    DeleteObject(hdcMemDC);
    ReleaseDC(NULL,hdcScreen);
    ReleaseDC(hWnd,hdcWindow);
    hb_retlTRUE );
}

Giovanni Di Maria

unread,
Sep 9, 2020, 2:54:44 PM9/9/20
to Harbour Users
Thank you very much.
Giovanni

Pete

unread,
Sep 9, 2020, 3:36:51 PM9/9/20
to Harbour Users

Hi Maurizio


On Wednesday, 9 September 2020 10:19:12 UTC+3, Maurizio la Cecilia wrote:

The major limitation is that the output file is a bitmap, thus I introduced a parameter to limit the size of the saved file.


You can overcome this 'limitation' by using hbfimage to convert/save the .bmp to .jpg (or to many other formats).
Practically, what you need is just two lines of code (I'm copying/adapting from hbfimage/test.prg):

   im := fi_Load( FIF_BMP, IMAGES_IN + "my.bmp", BMP_DEFAULT )
   fi_Save( FIF_JPEG, im, IMAGES_OUT + "my.jpg", JPEG_DEFAULT ) // jpeg format
   fi_Save( FIF_PNG , im, IMAGES_OUT + "my.png", PNG_DEFAULT  ) // png format

PS. very interesting your hbs_ScreenShot() function, thanks for sharing!

regards,
Pete






Maurizio la Cecilia

unread,
Sep 10, 2020, 12:21:06 PM9/10/20
to harbou...@googlegroups.com
Hi Pete,
thanks a lot for your suggestion.
I don't like so much to have DLLs in my app folder, thus until now I avoided FreeImage, but today I tried to apply the code you shown.
Unluckily something gone wrong because the jpg file isn't created at all (0 bytes long) and the png (42KB long) file is unreadable.
I'll try to deeper investigate...
Thanks again if you have some clue you're welcome.
Best regards.
--
Maurizio
--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

Pete

unread,
Sep 10, 2020, 1:52:50 PM9/10/20
to Harbour Users


On Thursday, 10 September 2020 19:21:06 UTC+3, Maurizio la Cecilia wrote:
Hi Pete,
thanks a lot for your suggestion.
I don't like so much to have DLLs in my app folder, thus until now I avoided FreeImage, but today I tried to apply the code you shown.
Unluckily something gone wrong because the jpg file isn't created at all (0 bytes long) and the png (42KB long) file is unreadable.

I must admit that I had not tested my suggestion and sadly I faced similar 'problem' today morning
when tried to combine your function with `hbfimage`. Mine failure though was worst, since I repeatedly
the sample I mad,e crashed with `Unrecoverable error 6005` , `ACCESS_VIOLATION` and such wonderful things
However, a plain hbfimage test code is working fine, doing flawlessly the 'conversion' from one format (bmp)
to another (jpg, png, etc) and vice-versa. I have no clue of what the root of problem might be.
Only a vague guess that the `bmp` produced by hbs_ScreenShot() might "have" something not compatible
to freeimage.

PS. I have the same view  for the DLLs, particularly due to the fact that the absence of a dll
may lead the application to become unusable. I prefer the self-completeness and independence
from external modules. On the other hand, this "independence"  has a price, which at times
can be undesirably high, which makes some DLLs  'best value for money' ;-)

regards,
Pete




Maurizio la Cecilia

unread,
Sep 10, 2020, 3:01:02 PM9/10/20
to harbou...@googlegroups.com
Hi Pete

Il 10/09/2020 19:52, Pete ha scritto:


On Thursday, 10 September 2020 19:21:06 UTC+3, Maurizio la Cecilia wrote:
Hi Pete,
thanks a lot for your suggestion.
I don't like so much to have DLLs in my app folder, thus until now I avoided FreeImage, but today I tried to apply the code you shown.
Unluckily something gone wrong because the jpg file isn't created at all (0 bytes long) and the png (42KB long) file is unreadable.

I must admit that I had not tested my suggestion and sadly I faced similar 'problem' today morning
when tried to combine your function with `hbfimage`. Mine failure though was worst, since I repeatedly
the sample I mad,e crashed with `Unrecoverable error 6005` , `ACCESS_VIOLATION` and such wonderful things
However, a plain hbfimage test code is working fine, doing flawlessly the 'conversion' from one format (bmp)
to another (jpg, png, etc) and vice-versa. I have no clue of what the root of problem might be.
Only a vague guess that the `bmp` produced by hbs_ScreenShot() might "have" something not compatible
to freeimage.

To be sure about hbs_ScreenShot() compatibility I did a simple test:

fi_Save( FIF_BMP, fi_Load( FIF_BMP, "hbs_ScreenShot.bmp", BMP_DEFAULT ), "freeimage.bmp", BMP_DEFAULT )

The produced freeimage.bmp is correctly open by graphical apps and is absolutely identical to the bmp file produced by the hbs_ScreenShot() function.

Maybe the conversion functions have some restriction (size?) on source image.

Best regards.
--
Maurizio


PS. I have the same view  for the DLLs, particularly due to the fact that the absence of a dll
may lead the application to become unusable. I prefer the self-completeness and independence
from external modules. On the other hand, this "independence"  has a price, which at times
can be undesirably high, which makes some DLLs  'best value for money' ;-)

regards,
Pete




--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

Maurizio la Cecilia

unread,
Sep 18, 2020, 12:13:11 PM9/18/20
to harbou...@googlegroups.com
Hi Pete,
I just returned on your suggestion and I found the solution was very simple.
My hbs_ScreenShot() doesn't render the bitmap in 8 or 24 bits depth, the needed depths by FreeImage conversion functions.
Thus it's just enough to convert the bitmap before to save:

      hbs_ScreenShotHb_GtInfo( HB_GTI_WINHANDLE ), cFileName + ".bmp" )
      fi_Save( FIF_PNG , fi_ConvertTo24Bitsfi_Load( FIF_BMP, cFileName + ".bmp", BMP_DEFAULT ) ), cFileName + ".png", PNG_DEFAULT  ) // png format

The PNG format is the best for saving the screenshot (no artefacts and lesser size than JPG).

I  hope this is useful for you.

The next steps will be to avoid the BMP save to disk and to call FreeImage functions directly in hbs_ScreenShot().

Thanks again for FreeImage clue.
Kind regards.
--
Maurizio

Il 10/09/2020 19:52, Pete ha scritto:
--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

Maurizio la Cecilia

unread,
Sep 18, 2020, 12:32:18 PM9/18/20
to Harbour User Group
A further step: no more needed the conversion.

Just edited the line:

    bi.biBitCount = 32;

setting it to:

    bi.biBitCount = 24;

The correct result is acquainted by:

      hbs_ScreenShotHb_GtInfo( HB_GTI_WINHANDLE ), cFileName + ".bmp" )
      fi_Save( FIF_PNG , fi_Load( FIF_BMP, cFileName + ".bmp", BMP_DEFAULT ), cFileName + ".png", PNG_DEFAULT  ) // png format

I'll publish a definitive version of hbs_ScreenShot() as soon I'll avoid to save the BMP.

Kind regards.
--
Maurizio

Pete

unread,
Sep 18, 2020, 1:35:53 PM9/18/20
to Harbour Users

Hi Maurizio,


On Friday, 18 September 2020 19:13:11 UTC+3, Maurizio la Cecilia wrote:
Hi Pete,
I just returned on your suggestion and I found the solution was very simple.

Yes, I believe you, most solutions are very simple, the only complicated part is how to locate them. :o)

 
My hbs_ScreenShot() doesn't render the bitmap in 8 or 24 bits depth, the needed depths by FreeImage conversion functions.
Thus it's just enough to convert the bitmap before to save:

      hbs_ScreenShotHb_GtInfo( HB_GTI_WINHANDLE ), cFileName + ".bmp" )
      fi_Save( FIF_PNG , fi_ConvertTo24Bitsfi_Load( FIF_BMP, cFileName + ".bmp", BMP_DEFAULT ) ), cFileName + ".png", PNG_DEFAULT  ) // png format

The PNG format is the best for saving the screenshot (no artefacts and lesser size than JPG).

I  hope this is useful for you.


I'm sure it'd be useful and not only for me but for every one who may need it.
I'd ask you to release the version 1.0 of your function (along with your sample test-code) to let us make a testing.
and when you find the solution of avoiding the .bmp creation you can release a version 1.5 ;-)

I'm not sure whether it would be feasible or not, but a solution could perhaps be to 'save' the intermediate .bmp
in memory (memio?) instead of disk. Just an idea, never tried such 'advanced tricks'.

regards,
Pete



Auge & Ohr

unread,
Sep 18, 2020, 1:43:58 PM9/18/20
to Harbour Users
hi,
hi,

i wonder why using a 3-PP DLL when Windows have "Print Screen"

you just need simple GDI Function from Bos Taurus

   hBitmap := BT_BitmapCaptureDesktop( Row, Col, Width, Height )

   BT_BitmapSaveFile
( hBitmap, cFileName, nTypePicture )

you also can use

   BT_BitmapCaptureWindow (Win, Row, Col, Width, Height)

   BT_BitmapCaptureClientArea
(Win, Row, Col, Width, Height)

so no need to use a 3-PP DLL to get a Snapshot

Maurizio la Cecilia

unread,
Sep 19, 2020, 3:52:30 AM9/19/20
to Harbour User Group
Hi,
I just wasn't aware of this set of functions because I'm not a HMG user.
I'll try to adopt this approach, avoiding the noising Free image.dll need.
Thanks a lot for the suggestion.
Best regards.
--
Maurizio


--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

Maurizio la Cecilia

unread,
Sep 23, 2020, 6:22:05 PM9/23/20
to harbou...@googlegroups.com
Hi,
Auge & Ohr suggestion it's very fine.
Today I found the time to study BosTaurus (a very nice piece of code) and how to use it outside HMG and easily did the job.

I just added BosTaurus_C.prg, BosTaurus.ch and mgdefs.h to my project and rewrote the function:



#include "bostaurus.ch"

function hbs_ScreenShot( cFileName, nImgType )

   local row       := Hb_GtInfo( HB_GTI_SETPOS_XY )[ 2 ]
   local col       := Hb_GtInfo( HB_GTI_SETPOS_XY )[ 1 ]
   local width     := Hb_GtInfo( HB_GTI_SCREENWIDTH )
   local height    := Hb_GtInfo( HB_GTI_SCREENHEIGHT )
   local maxwidth  := hb_GtInfo( HB_GTI_DESKTOPWIDTH )
   local maxheight := hb_GtInfo( HB_GTI_DESKTOPHEIGHT )
  
   /* reduce the output to the visible part of the app window */
   if col + width > maxwidth
      width := maxwidth - col
   endif
   if row + height > maxheight
      height := maxheight - row
   endif
  
   return BT_BMP_SaveFile( BT_BMP_CaptureScr( Hb_GtInfo( HB_GTI_WINHANDLE ), ;
                                              col, ;
                                              row, ;
                                              width, ;
                                              height, ;
                                              BT_BITMAP_CAPTURE_WINDOW ), ;
                           cFileName, ;
                           hb_defaultValue( nImgType, BT_FILEFORMAT_PNG ) )



I avoided to include BosTaurus_HB.prg because it contains some HMG dependencies and thus derived hbs_ScreenSho() from BT_BitmapCaptureWindow() .

Similarly, also the functions BT_BitmapCaptureDesktop() and BT_BitmapCaptureClientArea() could be easily imported.

Best regards.
--
Maurizio

Miroslav Georgiev

unread,
Dec 29, 2020, 5:18:59 PM12/29/20
to Harbour Users
Hi Maurizio.
Can you post your final code that has no dependencies on HMG? Thank you very much in advance!

Maurizio la Cecilia

unread,
Dec 31, 2020, 7:42:52 AM12/31/20
to harbou...@googlegroups.com
Hi Mirsolav,
not sure the list allows so large attachments.

However, here is it.

Best regards and happy new year.
--
Maurizio
hbs_screenshot.prg
hbs_bostaurus.c
hbs_bostaurus.ch

Miroslav Georgiev

unread,
Jan 1, 2021, 4:38:47 PM1/1/21
to Harbour Users
Thank you. And than you all. Happy new year.

In my case I continuously record user's desktop sessions (not just app's Windows but whole desktop). This gives me a better opportunity reproduce and resolve problems faster. Until now I used external EXE for screenshots. It worked reasonably well. Yet running external program every 250msec isn't efficient.
Now I incorporated your solution and it seems to work well. I hope this way of making screenshot be more efficient. I'm very happy with the new approach.

Due tomaking so many screenshots I noticed memory leakage, however. Corrected by adding BT_BitmapRelease( hBitmap ) after savng:
BT_BMP_SaveFile( hBitmap, cOutFile, BT_FILEFORMAT_PNG )
BT_BitmapRelease( hBitmap )

I work with GTWVT. I wanted to record high framerate when needed (when user presses keys) and less or no screenshots when user is idle. I detect screen changes via separate thread, comparing old frame with current frame every 250msec - via SaveScreen(). If change is detected I make screenshot. 

If anybody interested I can share.

Maurizio la Cecilia

unread,
Jan 1, 2021, 4:59:20 PM1/1/21
to Harbour User Group
Hi Miroslav, you're right.
Reading Bos Taurus doc carefully, it's absolutely needed to free bitmap allocated memory.
Unluckily Windows is lacking for a memory tool similar to valgrind, AFAIK.
Thanks for your feedback.
Best regards.
--
Maurizio


Reply all
Reply to author
Forward
0 new messages