Jump to content

Modify Screencapture Image


Recommended Posts

Hi,

I have the following code:

#include <ScreenCapture.au3>

GLobal $last_image_id = 0
Global $iVScrWidth=_WinAPI_GetSystemMetrics(78)
Global $iVScrHeight=_WinAPI_GetSystemMetrics(79)

_ScreenCapture_SetJPGQuality(10)


$timer = TimerInit()

while 1
    sleep (50)
    if TimerDiff($timer) >= 500 Then
        $last_image_id = $last_image_id + 1
        _ScreenCapture_Capture(@ScriptDir & "\" & $last_image_id & ".jpg", ($iVScrWidth/2) * -1 , 0,  $iVScrWidth/2, $iVScrHeight)
        exit
        $timer =TimerInit()
    EndIf
WEnd

What this code does is take 2 screenshots every second of our 2 monitor desktop setup with the right monitor being the main one.

Eventually I'll add in options where the user can select 1 monitor setups and 2 monitor setups with the main monitor being on different sides.

What I'm trying to do is the following:

  • get a reference to the HBITMAT instead of saving it to file (this is easy)
  • Reduce the width/height of the image by ~50%
  • Reduce the number of colors in the image?

These modifications are all geared toward reducing the file size of the images as they're all in 1920x1080.

Maybe someone has a better suggestion than the 3 points above?

Can anyone point me in the right direction?

I've looked into this and all I've been able to find is complex win_api calls and the like.

[font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]
Link to comment
Share on other sites

You could try _ScreenCapture_SetBMPFormat to save with less colours, or _GDIPlus_BitmapCloneArea if that doesn't do it. I'd then get it as a HBITMAP and use StretchBlt as thats the only way I know to scale images (but then again, I am not an expert on GDI+, and tend to use the windows api more).

You could also look at using compression of some description, there are zip and 7z and many others on the forum. Or take pics less often.

Link to comment
Share on other sites

I've tried _ScreenCapture_SetBMPFormat and the image size of BMP's are higher than quality 10 JPGs even at the lowest setting.

Also, the images must be saved 'as-is' ie. outside of zipped archives.

I'll have to look at stretch bit and clone area

[font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...