3 pièce(s) jointe(s)
Découpe d'image, différence entre deux fonctions
Bonjour,
j'ai deux procédures ayant le même objectif : découper une image
Pièce jointe 624441
la première
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| procedure TForm1.BtnClipClick(Sender: TObject);
procedure Decoupe(InBitmap, OutBitMap: TBitmap; Selection : TSelection);
var bmps : TBitmap;
iRect : TRect;
begin
Selection.HideSelection:=True;
bmps:=Image1.MakeScreenshot;
Selection1.HideSelection:=False;
OutBitMap.Width := Trunc(Selection.Width);
OutBitMap.Height := Trunc(Selection.Height);
iRect.Left :=Trunc(Selection.Position.X);
iRect.Top :=Trunc(Selection.Position.Y);
iRect.Width := Trunc(Selection.Width);
iRect.Height := Trunc(Selection.Height);
OutBitMap.CopyFromBitmap(InBitMap, iRect, 0, 0 );
bmps.Free;
end;
begin
Decoupe(Image1.Bitmap,Image2.Bitmap,Selection1);
end; |
Pièce jointe 624442
la seconde
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| procedure TForm1.btncropClick(Sender: TObject);
var bmps : TBitmap;
begin
Selection1.HideSelection:=True;
bmps:=Image1.MakeScreenshot;
Selection1.HideSelection:=False;
DecoupeBitmap(Bmps,Image2.Bitmap,Trunc(Selection1.Position.X),Trunc(Selection1.Position.y),Trunc(Selection1.Width),Trunc(Selection1.Height));
bmps.Free;
end;
procedure TForm1.DecoupeBitmap(InBitmap, OutBitMap: TBitmap; X, Y, W, H: integer);
var
iRect : TRect;
begin
OutBitMap.Width := W;
OutBitMap.Height := H;
iRect.Left :=X;
iRect.Top :=Y;
iRect.Width := W;
iRect.Height := H;
OutBitMap.CopyFromBitmap( InBitMap, iRect, 0, 0 );
end; |
Pièce jointe 624443
Pour moi, elles sont identiques, pourtant je n'obtiens le bon résultat qu'avec le second traitement :aie:
Problème de lunettes ce matin ou bien ?