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 29 30
| procedure TfrmGen.itemOuvrirClick(Sender: TObject);
const Filtre = 'Tous fichiers image (*.bmp;*.dib;*.rle;*.gif;*.ico;*.jpg;*jpeg;*.jpe;*.jfif;*.png;*.tif;*.tiff;*.emf;*.wmf)|*.bmp;*.dib;*.rle;*.gif;*.ico;*.jpg;*jpeg;*.jpe;*.jfif;*.png;*.tif;*.tiff;*.emf;*.wmf)'
+ '|BMP, DIB, RLE : Bitmaps |*.bmp|GIF : CompuServe |*.gif|ICO : Icônes|*.ico|JPG, JPEG, JPE, JFIF : Fichier JPEG|*.jpg'
+ '|PNG : Portable Network Graphics|*.png|TIF, TIFF : Format Tiff|*.tif|EMF : Méta-Fichier EMF|*.emf|WMF : Méta-Fichier WMF|*.wmf';
var
gra: IGPGraphics;
Image: IGPImage; img : tImage;
wi, hi, wf, hf: integer;
begin
imageFond.Align := alNone; imageFond.Update; // ImageFond est un TImage placé dans une ScrollBox
with OpenDialog1 do begin // OpenDialog1 pou éviter les problèmes causés par OpenPictureDialog
filter := Filtre;
if Execute then begin
Image := TGPImage.Create(FileName);
wi := Image.Width; hi := Image.Height;
wf := imageFond.Width; hf := imageFond.Height;
if wi > wf then begin imageFond.Width := wi; imageFond.Update; end;
if hi > hf then begin imageFond.Height := hi; imageFond.Update; end;
img := tImage.Create(self); //<- img : On est obligé de passer par l'intermédiaire d'un TImage taillé aux dimensions de l'image chargée sinon le DrawImage direct sur imageFond s'obstine à limiter le tracé aux dimensions initiales de conception de imageFond
img.Width:=wi; img.Height:=hi;
gra := TGPGraphics.Create(img.Canvas);
gra.DrawImage(Image, 0, 0, wi, hi);
imageFond.Picture.Bitmap.Assign(img.Picture.Bitmap);
imageFond.Repaint;
img.Free;
Caption := FileName + ' [' + IntToStr(wi) + 'x' + IntToStr(hi) + ']';
end;
end;
end; |
Partager