tiens j'ai pu retrouver ce code
en gros je fais des dessin sur le bureau en le faisant passer pour un canvas. Donc je peux utiliser toutes les méthodes de la classe TCanvas
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
PaintBox1: TPaintBox;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button2Click(Sender: TObject);
private
{ Déclarations privées}
bureau:TCanvas;
public
{ Déclarations publiques}
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
bureau := TCanvas.Create;
bureau.Handle := GetDC(hWnd_Desktop);
end;
procedure TForm1.Button1Click(Sender: TObject);
Var h,ht:longint;
begin
bureau.Pen.Color := clWhite;
bureau.Font.Name := 'Courier New';
bureau.Font.Size := Trunc(Screen.Width / 6.4);
ht := bureau.TextHeight('Blaireu');
h := 0;
while ( h < Screen.Height ) do
begin
bureau.Textout(0,h,'Blaireau');
h := h + ht;
end;
Form1.Hide;
Form1.Show;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
{ bureau.Pen.Color := clBlack;
bureau.FillRect(Rect(0,0,Screen.Width-1,Screen.Height-1));
}end;
procedure TForm1.Button2Click(Sender: TObject);
Var c,r,v,b:longint;
nx,ny:longint;
px,py:longint;
bx,by:longint;
nb:longint;
x,y:longint;
tmp:array [0..319,0..239] of longint;
begin
// zomm inverse
{ initialisation }
PaintBox1.Canvas.CopyRect(Rect(0,0,320,240),bureau,Rect(0,0,Screen.Width,Screen.Height));
{ nx := Screen.Width div 320;
ny := Screen.Height div 200;
for x := 0 to 319 do
for y := 0 to 239 do
begin
px := nx * x;
py := ny * y;
r := 0;
v := 0;
b := 0;
nb := 0;
for bx := px to (px+nx - 1) do
for by := py to (py+ny - 1) do
begin
inc(nb);
c := bureau.Pixels[bx,by];
r := r + ((c shr 16) and 255);
v := v + ((c shr 8) and 255);
b := b + ( c and 255);
end;
r := r div nb;
v := v div nb;
b := b div nb;
tmp[x,y] := (r shl 16) + (v shl 8) + b;
end;
for x := 0 to 319 do
for y := 0 to 239 do
PaintBox1.Canvas.Pixels[x,y] := tmp[x,y];}
end;
end.