ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 CaptureFromScreen on windows 10 works invalid
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

wolf1860

China
15 Posts

Posted - Sep 15 2015 :  03:41:00  Show Profile  Reply
Everything is correct except on windows10:
if CaptureFromScreen(TIMageEnView.IO) excecute,everything on the screen move to right and I can't get correct data,like this:
before Capture:

Execute capture:The text size and the picture's position are changed.

xequte

38517 Posts

Posted - Sep 15 2015 :  16:52:14  Show Profile  Reply
Hi

I can't reproduce any issue on Windows 10. Can you show me the code you are using?

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

wolf1860

China
15 Posts

Posted - Sep 16 2015 :  08:29:19  Show Profile  Reply
Thanks for reply:)
My apllication is very simple:
I use a form with a TImageEnView,this form is used to capture screen,the first button is to do the capture action#65292;like this:

with img1 do
begin
// Blank;
IO.CaptureFromScreen();
zoom:=100;
DeSelect;
end;

It works fine except windows10.The capture result is transformed.It looks to be enlarged and blured.The annex is my application source.



attach/wolf1860/20159168274_CaptureScreen_ImageEn.zip
62.35 KB
Go to Top of Page

w2m

USA
1990 Posts

Posted - Sep 16 2015 :  10:38:39  Show Profile  Reply
I can not duplicate your findings with your demo on Delphi 10 Seattle with Windows 10. The screen capture is not enlarged and is not blurred.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

wolf1860

China
15 Posts

Posted - Sep 16 2015 :  12:01:22  Show Profile  Reply
Thanks a lot!
The windows system is chinese version and is upgraded from win8.1,maybe I should practise my application on more computers....
Go to Top of Page

wolf1860

China
15 Posts

Posted - Sep 16 2015 :  18:48:46  Show Profile  Reply
The problem only takes place on surface,Everything is ok on normal PC.
Did Anyone find this? Any advice else?
Go to Top of Page

w2m

USA
1990 Posts

Posted - Sep 17 2015 :  15:07:35  Show Profile  Reply
Unfortunately, I still do not know why for sure as I have never seen the screen dimensions reported incorrectly with Delphi before, but it is likely. I tested the screen capture on my Surface 3 Pro with ImageEn as well as with my Apprehend Screen Capture component (http://www.frontiernet.net/~w2m/Apprehend62.zip). For some reason on Windows 10, the Surface desktop capture does not capture the full desktop. Only about 1/4 of the desktop is captured. As a result, the image appears as though it is zoomed. I am not sure why however, but the Surface screen is higher resolution and about 1/2 the size of most desktop monitors which may be causing the problem.

Update:
While investigating this I found that my Surface Pro tablet has a Screen resolution of 2,160 x 1,440 (the default recommended setting). Screen.Width returns only 1,080 and Screen.Height returns only 730 on the Surface.... This is the root of the problem. Maybe it has something to do with high dpi? The Delphi forms dpi is 96, but maybe this has to be adjusted to a higher value... Wow!

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

wolf1860

China
15 Posts

Posted - Sep 17 2015 :  18:53:10  Show Profile  Reply
It means that there is no solution to capture the screen of surface with imageEn at present? Anyway,thks again:)
Go to Top of Page

xequte

38517 Posts

Posted - Sep 17 2015 :  21:19:49  Show Profile  Reply
Hi

Please see this explanation with regard to high DPI awareness:

http://stackoverflow.com/questions/26089963/wrong-resolution-reported-by-screen-width-when-make-it-easier-to-read-whats-on

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

w2m

USA
1990 Posts

Posted - Sep 18 2015 :  10:24:14  Show Profile  Reply
Problem solved!

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
  Vcl.StdCtrls, hyieutils, iexBitmaps, hyiedefs, iesettings, ieview,
  imageenview, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Button1: TButton;
    ImageEnView1: TImageEnView;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{Note: Screen.Width and Screen.Height produce incorrect results when using Screen.Width
 and Screen.Height to set the dimensions of a bitmap for screen capture on high resolution
 monitor similar to that on a Microsoft Surface Pro 3.  Both GetDeviceCaps and Monitor return
 the correct screen dimensions on a Surface 3 Pro and on Desktop monitors while Screen.Height and
 Screen.Width does not.  I attempted to use WMI to achieve the same result but this failed
 to function in my tests.  Subsequently it was determined that both GetDeviceCaps as well as
 Monitor returns the correct values.  Tested on Windows 10 on a Desktop PC and Desktop Monitor
 as well as with a Surface Pro 3 Tablet with Windows 10. Compiled with Delphi 10 Seattle. }

procedure ScreenShot(ActiveWindow: bool; DestBitmap: TBitmap);
{ Capture the desktop using GetDeviceCaps rather than Screen.Width and Screen.Height }
var
  iWidth: integer;
  iHeight: integer;
  DC: HDC;
  hWin: Cardinal;
  iRect: TRect;
begin
  if ActiveWindow then
  begin
    hWin := GetForegroundWindow;
    DC := GetWindowDC(hWin);
    GetWindowRect(hWin, iRect);
    iWidth := iRect.Right - iRect.Left;
    iHeight := iRect.Bottom - iRect.Top;
  end
  else
  begin
    hWin := GetDesktopWindow;
    DC := GetDC(hWin);
    iWidth := GetDeviceCaps(DC, HORZRES);
    iHeight := GetDeviceCaps(DC, VERTRES);
  end;
  try
    DestBitmap.Width := iWidth;
    DestBitmap.Height := iHeight;
    BitBlt(DestBitmap.Canvas.Handle, 0, 0, DestBitmap.Width, DestBitmap.Height,
      DC, 0, 0, SRCCOPY);
  finally
    ReleaseDC(hWin, DC);
  end;
end;

procedure ScreenShot2(ActiveWindow: bool; DestBitmap: TBitmap);
{ Capture the desktop using Monitor rather than Screen.Width and Screen.Height }
var
  iWidth: integer;
  iHeight: integer;
  DC: HDC;
  hWin: Cardinal;
  iRect: TRect;
begin
  if ActiveWindow then
  begin
    hWin := GetForegroundWindow;
    DC := GetWindowDC(hWin);
    GetWindowRect(hWin, iRect);
    iWidth := iRect.Right - iRect.Left;
    iHeight := iRect.Bottom - iRect.Top;
  end
  else
  begin
    hWin := GetDesktopWindow;
    DC := GetDC(hWin);
    iWidth := Form1.Monitor.Width;
    iHeight := Form1.Monitor.Height;
  end;
  try
    DestBitmap.Width := iWidth;
    DestBitmap.Height := iHeight;
    BitBlt(DestBitmap.Canvas.Handle, 0, 0, DestBitmap.Width, DestBitmap.Height,
      DC, 0, 0, SRCCOPY);
  finally
    ReleaseDC(hWin, DC);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
{ Capture an image of the Desktop screen on high res monitors by using
  GetDeviceCaps to set the bitmap dimensions. Tested on a Surface Pro 3.}
begin
  WindowState := wsMinimized;
  Sleep(250);
  ImageEnView1.Bitmap.PixelFormat := pf24bit;
  ScreenShot(False, ImageEnView1.Bitmap);
  ImageEnView1.Update;
  WindowState := wsNormal;
end;

procedure TForm1.Button2Click(Sender: TObject);
{ Capture an image of the Desktop screen on high res monitors by using
  Monitor to set the bitmap dimensions. Tested on a Surface Pro 3.}
begin
  WindowState := wsMinimized;
  Sleep(250);
  ImageEnView1.Bitmap.PixelFormat := pf24bit;
  ScreenShot2(False, ImageEnView1.Bitmap);
  ImageEnView1.Update;
  WindowState := wsNormal;
end;

end.


Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: