AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

nur weiße screenshotes

Ein Thema von Harry M. · begonnen am 17. Apr 2005 · letzter Beitrag vom 19. Apr 2005
Antwort Antwort
Benutzerbild von Harry M.
Harry M.

Registriert seit: 29. Okt 2004
Ort: Halle
462 Beiträge
 
#1

Re: nur weiße screenshotes

  Alt 19. Apr 2005, 03:05
bitte schön:
Delphi-Quellcode:
uses Jpeg;
var
  PIC : TImage;
  fNameJPG, S : string;

////////////////////////////////////////////////////////////////////////////////
function GetCursorInfo2: TCursorInfo;
var
hWindow: HWND;
pt: TPoint;
pIconInfo: TIconInfo;
dwThreadID, dwCurrentThreadID: DWORD;
begin
Result.hCursor := 0;
ZeroMemory(@Result, SizeOf(Result));
// Find out which window owns the cursor
if GetCursorPos(pt) then
begin
   Result.ptScreenPos := pt;
   hWindow := WindowFromPoint(pt);
   if IsWindow(hWindow) then
   begin
     // Get the thread ID for the cursor owner.
     dwThreadID := GetWindowThreadProcessId(hWindow, nil);

     // Get the thread ID for the current thread
     dwCurrentThreadID := GetCurrentThreadId;

     // If the cursor owner is not us then we must attach to
     // the other thread in so that we can use GetCursor() to
     // return the correct hCursor
     if (dwCurrentThreadID <> dwThreadID) then
     begin
       if AttachThreadInput(dwCurrentThreadID, dwThreadID, True) then
       begin
         // Get the handle to the cursor
         Result.hCursor := GetCursor;
         AttachThreadInput(dwCurrentThreadID, dwThreadID, False);
       end;
     end
     else
     begin
       Result.hCursor := GetCursor;
     end;
   end;
end;
end;
////////////////////////////////////////////////////////////////////////////////
function setJPGFileName(fbmp: string):string;
var
  I : integer;
begin
  s := ExtractFileName(fbmp);
  for i := 1 to 3 do Delete(s,Length(s),1);
  result := s + 'JPG'
end;
////////////////////////////////////////////////////////////////////////////////
procedure ScreenShot(Bild: TBitMap);
var
  c: TCanvas;
  r: TRect;
  MyCursor: TIcon;
  CursorInfo: TCursorInfo;
  IconInfo: TIconInfo;
begin
  c := TCanvas.Create;
  c.Handle := GetWindowDC(GetDesktopWindow);
  try
    r := Rect(0, 0, Screen.Width, Screen.Height);
    Bild.Width := Screen.Width;
    Bild.Height := Screen.Height;
    Bild.Canvas.CopyRect(r, c, r);


      // Create temp. Icon
   MyCursor := TIcon.Create;
   try
     // Retrieve Cursor info
     CursorInfo := GetCursorInfo2;
     if CursorInfo.hCursor <> 0 then begin
       MyCursor.Handle := CursorInfo.hCursor;
       // Get Hotspot information
       GetIconInfo(CursorInfo.hCursor, IconInfo);
       // Draw the Cursor on our bitmap
       Bild.Canvas.Draw(CursorInfo.ptScreenPos.X - IconInfo.xHotspot, CursorInfo.ptScreenPos.Y - IconInfo.yHotspot, MyCursor);
     end;
   finally
     // Clean up
     MyCursor.ReleaseHandle;
     MyCursor.Free;
   end;


  finally
    ReleaseDC(0, c.Handle);
    c.Free;
  end;
end;
////////////////////////////////////////////////////////////////////////////////

// screenshot machen
ScreenShot(Image1.Picture.BitMap);

// konvertieren
Try
pic := TImage.Create(nil);
pic.Picture := Image1.Picture;
with TJPEGImage.Create do begin
  Performance := jpBestQuality;
  CompressionQuality := 20;
  Assign(pic.Picture.Graphic);
  //fNameJPG := setJPGFileName('Temp.bmp');
  SaveToFile('Temp.jpg');
  Free
  end;
except; end;
pic.Free;
das der cursor nun mit angezeigt wird, lässt aber die resourcen wieder etwas mehr in anspruch nehmen. kommentiere das dann einfach aus um den unterschied festzustellen
Harry
Gruß Harry
www.H-Soft.info
  Mit Zitat antworten Zitat
Antwort Antwort


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 17:17 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 by Thomas Breitkreuz