function ScreenCapture:TBitmap; // this function captures the screen var ScreenDC: HDC; ARect:TRect; begin Result := TBitmap.Create; ARect := Rect(0,0,Screen.Width,Screen.Height); Result.Width := ARect.Right - ARect.Left; Result.Height := ARect.Bottom - ARect.Top; ScreenDC := GetDC( 0 ); try BitBlt( Result.Canvas.Handle, 0, 0, Result.Width, Result.Height, ScreenDC, ARect.Left, ARect.Top, SRCCOPY ); finally ReleaseDC( 0, ScreenDC ); end; end;
procedure TForm1.Button1Click(Sender: TObject); var tmp : TBitmap; begin tmp := ScreenCapture(); Image1.Picture.Assign(tmp); tmp.Destroy; end;
//You might also want to use this procedure, because the bmp is normally pretty huge //this converts the a Bitmap to a JPEG image
procedure TForm1.Button2Click(Sender: TObject); begin JPEGImage := JpgImg.TJPEGImage.Create(Self); with JPEGImage do begin Parent := Self; Top := Image1.Height; Left := 0; Height := 100; Width := 100; Canvas.Draw(0,0, ScreenCapture); end; end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin JPEGImage.Free; end;
Jeg fik dette link af Hermandsen, og så vile jeg gerne spørge sfredsted om, jeg må få/købe/hente hans program JpegImage. Må jeg det? (For at gøre det perfekt :])
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.