cs_Jean_Jean
Messages postés615Date d'inscriptiondimanche 13 août 2006StatutMembreDernière intervention13 décembre 2018
-
18 juin 2009 à 08:39
cs_Jean_Jean
Messages postés615Date d'inscriptiondimanche 13 août 2006StatutMembreDernière intervention13 décembre 2018
-
18 juin 2009 à 15:17
Bonjour,
Je suis Delphiste et j'aurai besoin de savoir à quel type StdPicture correspond en Delphi? Est-ce un Type TBitmap? Ou bien, à quel type le plus rapprochant de Delphi correspond-til? Merci...
Renfield
Messages postés17287Date d'inscriptionmercredi 2 janvier 2002StatutModérateurDernière intervention27 septembre 202174 18 juin 2009 à 13:49
j'ignore si c'est bien le genre de question a se poser...
tu cherches j'imaginee a porter du code VB en Delphi...
un StdPicture permet de manipuler (très succintement) une image. Dis m'en plus sur l'utilisation que tu en as vu, on pourras alors peut-etre etre d'une plus grande aide
cs_Jean_Jean
Messages postés615Date d'inscriptiondimanche 13 août 2006StatutMembreDernière intervention13 décembre 20183 18 juin 2009 à 15:17
Voici le code en cet instant :
Cela ne semble pas fonctionner, j'ai du aller trop vite dans la transposition...
Procedure Stretch(aImage : TImage; sPath : String; lMaxWidth, lMaxHeight : LongInt);
Var
lOldWidth,
lOldHeight,
lNewWidth,
lNewHeight : LongInt;
cRatio : Real;
oStd : TBitmap;
begin
{régule la taille MAX par défaut}
If (lMaxWidth <= 0) Or (lMaxWidth > aImage.Width) Then lMaxWidth := aImage.Width;
If (lMaxHeight <= 0) Or (lMaxHeight > aImage.Height) Then lMaxHeight := aImage.Height;
{charge l'image et récupère sa taille}
oStd := TBitMap.Create;
with oStd do
begin
LoadFromFile(sPath);
lOldWidth := oStd.Width;
lOldHeight := oStd.Height;
{orientation, on va étirer l'image au plus possible en touchant la taille
max autorisée avec le bord du type d'image.
l'autre côté peut tout de même dépasser}
If lOldWidth > lOldHeight Then
begin
{image réelle : paysage}
lNewWidth := lMaxWidth;
cRatio := lMaxWidth / lOldWidth;
lNewHeight := Round(lOldHeight * cRatio);
If lNewHeight > lMaxHeight Then
begin
{la hauteur dépasse, même manip}
cRatio := lMaxHeight / lNewHeight;
lNewHeight := lMaxHeight;
lNewWidth := round(lNewWidth * cRatio);
end;
end else
begin
{image réelle : portrait}
lNewHeight := lMaxHeight;
cRatio := lMaxHeight / lOldHeight;
lNewWidth := Round(lOldWidth * cRatio);
If lNewWidth > lMaxWidth Then
begin
{la largeur dépasse, même manip}
cRatio := lMaxWidth / lNewWidth;
lNewWidth := lMaxWidth;
lNewHeight := round(lNewHeight * cRatio);
end;
End;
end;
{on dessine le rendu centré (NB : l'API StretchBlt donne une trop mauvaise
qualité, autant passer par la méthode accessible par le contrôle)}
aImage.Picture.Assign(oStd);
oStd.Free;
End;
procedure TForm1.FormPaint(Sender: TObject);
begin
Stretch(Image1,ExtractFilePath(application.ExeName)+'\Croix1.bmp',
Image1.Width div 2, Image1.Height div 2);
end;
Merci pour vos remarques!
Jean_Jean