Cirec
Messages postés
3833
Date d'inscription
vendredi 23 juillet 2004
Statut
Modérateur
Dernière intervention
18 septembre 2022
50
1 mars 2006 à 13:57
Salut,
Voici un petit exemple simple
ce n'est qu'une ébauche vite faite on peut encore facilement optimiser le code
Il faut que l'image contenue dan Image1 soit un Bmp
procedure TForm1.Button1Click(Sender: TObject);
Var Bmp1, Bmp2, Bmp3, Bmp4 : TBitMap;
aWidth, aHeight : Integer;
begin
// pour obtenir 4 Bmp on divise la hauteur et la largeure par 2
aWidth := Image1.Width div 2;
aHeight := Image1.Height div 2;
// on crée les 4 Bitmap et on les mets à la bonne taille
Bmp1 := TBitmap.Create;
Bmp1.Width := aWidth;
Bmp1.Height:= aHeight;
Bmp2 := TBitmap.Create;
Bmp2.Width := aWidth;
Bmp2.Height:= aHeight;
Bmp3 := TBitmap.Create;
Bmp3.Width := aWidth;
Bmp3.Height:= aHeight;
Bmp4 := TBitmap.Create;
Bmp4.Width := aWidth;
Bmp4.Height:= aHeight;
// on copie chaque partie dans les Bitmap
Bmp1.Canvas.CopyRect(Rect(0,0,aWidth,aHeight), Image1.Picture.Bitmap.Canvas,Rect(0,0,aWidth,aHeight));
Bmp2.Canvas.CopyRect(Rect(0,0,aWidth,aHeight), Image1.Picture.Bitmap.Canvas,Rect(aWidth,0,aWidth*2,aHeight));
Bmp3.Canvas.CopyRect(Rect(0,0,aWidth,aHeight), Image1.Picture.Bitmap.Canvas,Rect(0,aHeight,aWidth,aHeight*2));
Bmp4.Canvas.CopyRect(Rect(0,0,aWidth,aHeight), Image1.Picture.Bitmap.Canvas,Rect(aWidth,aHeight,aWidth*2,aHeight*2));
// on les affiches sur la form pour voir le résultat
Canvas.Draw(0,0, Bmp1);
Canvas.Draw(aWidth,aHeight, Bmp2);
Canvas.Draw(aWidth*2,aHeight*2, Bmp3);
Canvas.Draw(aWidth*3,aHeight*3, Bmp4);
// et on libère les Bitmap que l'on à crées
Bmp1.Free;
Bmp2.Free;
Bmp3.Free;
Bmp4.Free;
end;
@+
Cirec