Bonjour,
Je souhaite redimensionner une image JPEG affichée dans un Timage.
Pour cela je me suis inspiré du code fournit dans ce forum: http://www.developpez.net/forums/sho...age+TBitMap%3B
Seulement j'ai toujours des problèmes (l'image s'affiche, mais il n'y a pas de redimentionnement )
Voici ma fonction qui gère le redimentionnement:
Si quelqu'un peut me dire ce qui ne va pas dans mon code...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 procedure Timage1.LoadImageJPEG(fichier:ansistring;FImage1: Timage); Var ImageJPEG : TJPEGImage; ImageBmp : TBitMap; Ratio: double; begin ImageJPEG:=TJPEGImage.Create; Try ImageJPEG.LoadFromFile(fichier); if (ImageJpeg.Empty) then Exit; ImageBmp:=TBitMap.Create; Try ImageBmp.Assign(ImageJPEG); Ratio := ImageJpeg.Height / ImageJpeg.Width; if Ratio > 1 then ImageBmp.Width := Round(image1.Width / Ratio) else ImageBmp.Width := Fimage1.Width; ImageBmp.Height := Round(ImageBmp.Width * Ratio); ImageBmp.Canvas.StretchDraw(ImageBmp.Canvas.ClipRect, ImageJpeg); FImage1.Picture.BitMap.Assign(ImageBmp); finally ImageBmp.Free; end; Finally ImageJPEG.Free; end; end;
Merci d'avance.
Partager