procedure CaptureScreen;
var
DC: HDC;
mypng:TPNGObject;
Bitmap:TBitmap;
begin
// Capture the Desktop screen
DC := GetDC(GetDesktopWindow);
Bitmap := TBitmap.Create;
mypng:=TPNGOBJect.create;
try
Bitmap.Width := GetDeviceCaps(
DC, HORZRES);
Bitmap.Height := GetDeviceCaps(
DC, VERTRES);
BitBlt(Bitmap.Canvas.Handle,0,0,Bitmap.Width,Bitmap.Height,
DC,0,0,SRCCOPY);
Bitmap.SaveToFile('
normalBitmap.bmp');
mypng.Assign(Bitmap);
mypng.SaveToFile('
normalPng.png');
finally
ReleaseDC(GetDesktopWindow,
DC);
Bitmap.Free;
mypng.Free;
end;
end;
procedure CaptureScreen32;
var
DC: HDC;
mypng:TPNGObject;
Bitmap,b,SmallBitmap:TBitmap32;
bmap:TBitmap;
resmplr: TKernelResampler;
scalefactor : double;
x,y:integer;
begin
// Capture the Desktop screen
DC := GetDC(GetDesktopWindow);
Bitmap := TBitmap32.Create;
try
Bitmap.Width := GetDeviceCaps(
DC, HORZRES);
Bitmap.Height := GetDeviceCaps(
DC, VERTRES);
BitBlt(Bitmap.Canvas.Handle,0,0,Bitmap.Width,Bitmap.Height,
DC,0,0,SRCCOPY);
finally
ReleaseDC(GetDesktopWindow,
DC);
end;
scalefactor := 0.8;
x := round(Bitmap.Width*scalefactor);
y := round(Bitmap.Height*scalefactor);
b := TBitmap32.Create;
SmallBitmap := TBitmap32.Create;
bmap:=TBitmap.Create;
mypng:=TPNGOBJect.create;
try
resmplr := TKernelResampler.Create(b);
resmplr.Kernel := TLanczosKernel.Create;
SmallBitmap.SetSize(x,y);
resmplr.Resample(SmallBitmap,rect(0,0,x,y),rect(0,0,x,y),Bitmap,rect(0,0,Bitmap.Width,Bitmap.Height),dmOpaque,
nil);
SmallBitmap.SaveToFile('
reduced.bmp');
bmap.Width := smallbitmap.Width;
bmap.Height := smallbitmap.Height;
bmap.Assign(Smallbitmap);
mypng.Assign(bmap);
mypng.SaveToFile('
reduced.png');
finally
b.free;
Bitmap.free;
SmallBitmap.free;
bmap.free;
mypng.free;
end;
end;