Jump to content

What's wrong with this picture (when displayed with GUICtrlCreatePic)?


Go to solution Solved by LarsJ,

Recommended Posts

Posted

Here's a simple script I'm testing the ScreenCapture function with.

#include <ScreenCapture.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

; Capture region
_ScreenCapture_Capture(@ScriptDir & "\image.bmp", 290,18,1465,652,0)

$form=GUICreate("Test",1175,634,290,18,BitOR($WS_SYSMENU,$WS_POPUP),$WS_EX_COMPOSITED)


$PSimage=GUICtrlCreatePic(@ScriptDir & "\image.bmp", 0,0,1175,634)
GUISetState(@SW_SHOW)

MsgBox(0,"","Test of screen cap and display.")

.

The above script captures an area of the screen (the SciTE editor with this script open), writes it to image.bmp, and displays image.bmp. The problem I'm having is when image.bmp is displayed using GUICtrlCreatePic the result is fuzzy.  Here's a SnagIt screen capture of what GUICtrlCreatePic displays.

133k.png

 

Attached is image.bmp, which is sharp and equivalent to seeing the actual script open in SciTE on-screen.

Any suggestions for displaying an accurate rendition of ScreenCapture's output? (Must be borderless, no chrome, etc. -- equivalent to what my test script yields.)

image.bmp

 

 

  • Solution
Posted (edited)

For the specific example in the first post the cause for the flicker is possibly that the picture is resized.

If you make a screen capture with this command you'll get a much better picture:

_ScreenCapture_Capture(@ScriptDir & "\image.bmp", 290,18,1465-1,652-1,0)

If you need to resize the image you should not do it as simple as this. Use GDIPlus as UEZ has proposed or use a proper program.

Edited by LarsJ
Posted

Thank you, LarsJ!!

I had no intention of resizing; just capturing the screen area and displaying it at 100%. I thought the screen capture dimensions in my example are 1175x634, so I could use the same values in GUICreate and GUITCtrlCreatePic. Why the need to capture one pixel less than the space (or am I just being dense)?

Posted

You have miscalculated the size of the rectangle you're capturing. The formula to calculate the width of a rectangle on screen with left and right borders x1 and x2 when both borders are included is:

width = x2 - x1 + 1
Same for height. The size of the captured rectangle in the first post is 1176x635.
Posted

You have miscalculated the size of the rectangle you're capturing. The formula to calculate the width of a rectangle on screen with left and right borders x1 and x2 when both borders are included is:

width = x2 - x1 + 1
Same for height. The size of the captured rectangle in the first post is 1176x635.

 

 

Thank you, LarsJ!

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
×
×
  • Create New...