AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language Delphi MagSetWindowFilterList function not remove specified window of screenshot

MagSetWindowFilterList function not remove specified window of screenshot

Ein Thema von flashcoder · begonnen am 27. Jan 2018 · letzter Beitrag vom 29. Jan 2018
Antwort Antwort
Fukiszo
(Gast)

n/a Beiträge
 
#1

AW: MagSetWindowFilterList function not remove specified window of screenshot

  Alt 27. Jan 2018, 20:48
Delphi-Quellcode:
 MyBitmap.Canvas.CopyRect(Rect(0, 0, MyBitmap.Width, MyBitmap.Height), Canvas,
                               Rect(0, 0, r.Width, r.Height));
Delphi-Quellcode:
my example was made for a full screen, not part of screen
use it like this:
 MyBitmap.Canvas.CopyRect(Rect(X.Start, Y.Start, X.End, Y.End), Canvas,
                          Rect(X.Start, Y.Start, X.End, Y.End));

X and Y are Screen Offsets, not your Application Window Offsets
eg, Position [0,0] = topleft screen corner and not your application windows coordinate!
but better wait, others may give much better methods than my rude ones.

Geändert von Fukiszo (27. Jan 2018 um 20:56 Uhr)
  Mit Zitat antworten Zitat
flashcoder

Registriert seit: 10. Nov 2013
83 Beiträge
 
#2

AW: MagSetWindowFilterList function not remove specified window of screenshot

  Alt 27. Jan 2018, 21:52
@Fukiszo,

i tried your two suggestions and none works, but this can be the reason:

Zitat:
Saving the data

Normally, we could save the content of a window into a file, or copy its content into memory by using the BitBlt function. The main problem while saving the captured data by the magnification library is that we cannot access the bitmap of the host window or the magnification window with the BitBlt function as usual. So we use a work around by using the MagSetImageScalingCallback() function, which is described as below.
This alert can be found on C++ example linked on question.
So, i think that with BMP.Canvas.CopyRect() also not is different.
  Mit Zitat antworten Zitat
Fukiszo
(Gast)

n/a Beiträge
 
#3

AW: MagSetWindowFilterList function not remove specified window of screenshot

  Alt 27. Jan 2018, 22:04
sorry i dont know MagXXXXX.pas units neither their .dll,
i gave general examples,
if MAGxxx uses overlay to display something, my method fail. that i think your warning is telling.
I'm sorry!

...using the MagSetImageScalingCallback() function, which is described as below...
can you show that?

Geändert von Fukiszo (27. Jan 2018 um 22:07 Uhr)
  Mit Zitat antworten Zitat
flashcoder

Registriert seit: 10. Nov 2013
83 Beiträge
 
#4

AW: MagSetWindowFilterList function not remove specified window of screenshot

  Alt 27. Jan 2018, 22:14
...using the MagSetImageScalingCallback() function, which is described as below...
can you show that?
@Fukiszo, i still will try translate this part

Geändert von flashcoder (27. Jan 2018 um 22:23 Uhr)
  Mit Zitat antworten Zitat
Fukiszo
(Gast)

n/a Beiträge
 
#5

AW: MagSetWindowFilterList function not remove specified window of screenshot

  Alt 27. Jan 2018, 22:18
if it is allowed, upload the 80kb source, i dont have access on your link to look at.
edit: forget it, i just scrolled down and what i read is pretty simple,
when you translated the callback part you automatic have imported BMP format from where you can create hundrets of copies.

Code:
LONG lineSize = bmif.biWidth * bmif.biBitCount / 8;
BYTE* pLineData = new BYTE[lineSize];
BYTE* pStart;
BYTE* pEnd;
LONG lineStart = 0;
LONG lineEnd = bmif.biHeight - 1;
while (lineStart < lineEnd)
{
   // Get the address of the swap line
   pStart = pData + (lineStart * lineSize);
   pEnd = pData + (lineEnd * lineSize);
   // Swap the top with the bottom
   memcpy(pLineData, pStart, lineSize);
   memcpy(pStart, pEnd, lineSize);
   memcpy(pEnd, pLineData, lineSize);
   // Adjust the line index
   lineStart++;
   lineEnd--;

delete pLineData;
at that point the image is ready

Geändert von Fukiszo (27. Jan 2018 um 22:26 Uhr)
  Mit Zitat antworten Zitat
flashcoder

Registriert seit: 10. Nov 2013
83 Beiträge
 
#6

AW: MagSetWindowFilterList function not remove specified window of screenshot

  Alt 27. Jan 2018, 22:29
if it is allowed, upload the 80kb source, i dont have access on your link to look at.
edit: forget it, i just scrolled down and what i read is pretty simple,
when you translated the callback part you automatic have imported BMP format from where you can create hundrets of copies.

Code:
LONG lineSize = bmif.biWidth * bmif.biBitCount / 8;
BYTE* pLineData = new BYTE[lineSize];
BYTE* pStart;
BYTE* pEnd;
LONG lineStart = 0;
LONG lineEnd = bmif.biHeight - 1;
while (lineStart < lineEnd)
{
   // Get the address of the swap line
   pStart = pData + (lineStart * lineSize);
   pEnd = pData + (lineEnd * lineSize);
   // Swap the top with the bottom
   memcpy(pLineData, pStart, lineSize);
   memcpy(pStart, pEnd, lineSize);
   memcpy(pEnd, pLineData, lineSize);
   // Adjust the line index
   lineStart++;
   lineEnd--;

delete pLineData;
at that point the image is ready
I attached the source file of C++ example on question
Look to the MagCaptureDlg.cpp file

Geändert von flashcoder (27. Jan 2018 um 22:33 Uhr)
  Mit Zitat antworten Zitat
flashcoder

Registriert seit: 10. Nov 2013
83 Beiträge
 
#7

AW: MagSetWindowFilterList function not remove specified window of screenshot

  Alt 28. Jan 2018, 01:30
Here is my complete code updated, i tried translate callback function (was a combine of these 2 links: LNK1 and LNK2), seems right but not is executing when MagSetImageScalingCallback api is called.


Delphi-Quellcode:
var
  Form1: TForm1;

implementation

uses
  Unit3, Magnification;

{$R *.dfm}

function ImageScaling(hwnd: hwnd; srcdata: Pointer; srcheader: MAGIMAGEHEADER;
  destdata: Pointer; destheader: MAGIMAGEHEADER; unclipped: TRect;
  clipped: TRect; dirty: HRGN): Boolean;
var
  lpbmih: TBitmapInfoHeader;
  lpbmi: TBitmapInfo;
  aBitmap: HBITMAP;
  aDC: HDC;
  bmp: TBitmap;
begin
  Fillchar(lpbmih, SizeOf(lpbmih), 0);
  lpbmih.biSize := SizeOf(lpbmih);
  lpbmih.biWidth := srcheader.width;
  lpbmih.biHeight := srcheader.height;
  lpbmih.biPlanes := 1;
  lpbmih.biBitCount := Floor(lpbmih.biSizeImage / lpbmih.biHeight /
    lpbmih.biWidth * 8);
  lpbmih.biCompression := BI_RGB;

  Fillchar(lpbmi, SizeOf(lpbmi), 0);
  lpbmi.bmiHeader.biSize := SizeOf(lpbmi.bmiHeader);
  lpbmi.bmiHeader.biWidth := srcheader.width;
  lpbmi.bmiHeader.biHeight := srcheader.height;
  lpbmi.bmiHeader.biPlanes := 1;
  lpbmi.bmiHeader.biBitCount :=
    Floor(lpbmi.bmiHeader.biSizeImage / lpbmi.bmiHeader.biHeight /
    lpbmi.bmiHeader.biWidth * 8);
  lpbmi.bmiHeader.biCompression := BI_RGB;

  aDC := GetWindowDC(hwnd);
  bmp := TBitmap.Create;
  aBitmap := 0;
  try
    aBitmap := CreateDIBitmap(aDC, lpbmih, 0, nil, lpbmi, DIB_RGB_COLORS);
    bmp.handle := aBitmap;
  finally
    DeleteObject(aBitmap);
    DeleteDC(aDC);
    bmp.Free;
  end;
  Result := True;
end;

procedure MagScreenShot;
var
  desktop, hwndMag: hwnd;
  desktoprect, sourceRect: TRect;
  filterList: THWNDArray;
  m_ScreenX, m_ScreenY, m_ScreenT, m_ScreenL: Integer;
begin

  if not Form3.Showing then
    Form3.Show;

  desktop := GetDesktopWindow;
  GetWindowRect(desktop, desktoprect);

  m_ScreenT := desktoprect.Top;
  m_ScreenL := desktoprect.Left;
  m_ScreenX := desktoprect.right;
  m_ScreenY := desktoprect.bottom;

  if (not MagInitialize) then
  begin
    Application.MessageBox('Init magnification failed', 'Error',
      mb_Ok + mb_IconError);
    Exit;
  end;

  hwndMag := CreateWindow(WC_MAGNIFIER, 'MagnifierWindow',
    WS_CHILD or MS_SHOWMAGNIFIEDCURSOR or WS_VISIBLE, 0, 0, m_ScreenX,
    m_ScreenY, Form1.handle, 0, hInstance, nil);

  if (hwndMag = 0) then
  begin
    Application.MessageBox('MagnifierWindow creation failed', 'Error',
      mb_Ok + mb_IconError);
    Exit;
  end;

  if (not MagSetImageScalingCallback(hwndMag, TMagImageScalingCallback(@ImageScaling))) then
  begin
    Application.MessageBox('Cannot set callback', 'Error',
      mb_Ok + mb_IconError);
    Exit;
  end;

  try
    filterList[0] := Form3.handle;
  except
  end;

  if (not MagSetWindowFilterList(hwndMag, MW_FILTERMODE_EXCLUDE, 1,
    @filterList[0])) then
  begin
    Application.MessageBox('Cannot exclude main window', 'Error',
      mb_Ok + mb_IconError);
    Exit;
  end;

  sourceRect.Top := m_ScreenT;
  sourceRect.Left := m_ScreenL;
  sourceRect.right := m_ScreenX;
  sourceRect.bottom := m_ScreenY;

  if (not MagSetWindowSource(hwndMag, sourceRect)) then
  begin
    Application.MessageBox('Cannot set source to MagnifierWindow', 'Error',
      mb_Ok + mb_IconError);
    Exit;
  end;

  { if (not MagUninitialize) then
    begin
    Application.MessageBox('Finalize magnification failed', 'Error',
    mb_Ok + mb_IconError);
    Exit;
    end; }

end;

procedure TForm1.tmr1Timer(Sender: TObject);
begin
  MagScreenShot;
end;
Timer is be to 10000ms

Geändert von flashcoder (28. Jan 2018 um 02:20 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:28 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz