procedure TForm1.Button1Click(Sender: TObject);
var Fullscreen:Tbitmap;
FullscreenCanvas:TCanvas;
Dc:HDC;
x,y, K: Integer;
P : PByteArray;
begin
Hide;
Fullscreen := TBitmap.Create;
Fullscreen.Width := screen.width;
Fullscreen.Height := screen.Height;
DC:=GetDC(0);
try
FullscreenCanvas := TCanvas.Create; //创建一个CANVAS对象
try
FullscreenCanvas.Handle := DC;
Fullscreen.Canvas.CopyRect(Rect(0, 0, screen.Width, screen.Height), fullscreenCanvas,Rect (0, 0, Screen.Width, Screen.Height));
finally
FullscreenCanvas.Free; //释放CANVAS对象
end;
finally
ReleaseDC (0, DC); //释放DC
end;
//*******************************
Fullscreen.PixelFormat:=pf24bit;
for y:=0 to Fullscreen.Height -1 do
begin
P := Fullscreen.ScanLine[y];
for x := 0 to Fullscreen.Width -1 do
begin
K :=(P[x*3]+P[x*3+1]+P[x*3+2])Div 3;
P[x*3] := K;
P[x*3+1] := K;
P[x*3+2] := K;
end;
end;
//Fullscreen.PixelFormat:=pf8bit;
//*******************************
image1.picture.Bitmap:=fullscreen;//拷贝下的图象赋给IMAGE对象
image1.Width:=fullscreen.Width;
image1.Height:=fullscreen.Height;
fullscreen.free; //释放bitmap
Show; //显示窗口
end;