I have used a function to create screenshot of my desktop in Delphi 7. I am getting correct screenshots, however the picture taken has a size of around 3 MB. Normally, screenshots have a size of 150 KB or so. I am not sure why.
Here is my code:
procedure TForm1.btnDesktopShotClick(Sender: TObject);
VAR
ScreenH, ScreenW : Integer;
dc : HDC;
hWin :Cardinal;
bm : TBitMap;
begin
//get handle of desktop
try
hWin :=GetDesktopWindow;
dc:=getDC(hWin);
ScreenH :=GetDeviceCaps(dc,VertRes);
ScreenW :=GetDeviceCaps(dc,HORZRES );
//set bitmap
bm:=TBitmap.Create;
bm.Width :=ScreenW ;
bm.Height :=ScreenH ;
//copy to dest bitmap
BitBlt(bm.Canvas.Handle,0,0,bm.Width ,bm.Height ,dc,0,0,SRCCOPY );
Image1.Picture.Bitmap.Assign(bm);
Image1.Picture.SaveToFile('screenShotDesktop.jpeg');
finally
ReleaseDC(hWin,DC);
end;
end;
Help will be appreciated.
Thanks
Your saved file is a bmp format, example of saving a jpeg: