![]() |
Welche Grafikart befindet sich TPicture Variable?
Hey DPler,
ich möchte herausfinden was für eine Grafik in der Variable Bild ist (GIF,JPEG,WMF,BMP,PNG). Eine Möglichkeit ist über den Suffix von Opendialog.Filename zu gehen. Gibt es noch eine andere Möglichkeit? Mein Quelltext:
Delphi-Quellcode:
Danke Merowingerprocedure TMainForm.BImageOpenClick(Sender: TObject); var Bild : TPicture; begin if OpenPictureDialog.Execute then begin Bild := TPicture.Create; Bild.LoadFromFile(OpenPictureDialog.FileName); //Hier die Prüfung Bild.Free; end; end; |
Re: Welche Grafikart befindet sich TPicture Variable?
|
Re: Welche Grafikart befindet sich TPicture Variable?
Danke für die Antwort. Ich dachte es gibt vielleicht noch eine andere Variante die das Problem etwas eleganter löst.
Danke Merowinger |
Re: Welche Grafikart befindet sich TPicture Variable?
Nein. der Typ der Grafik wird nicht in TPicture gespeichert, da die Grafiken intern als Bitmap behandelt werden.
Man könnte sich aber einen eigenen Typ von TPicture ableiten und dort solch eine Option einbauen. |
Re: Welche Grafikart befindet sich TPicture Variable?
Der Typ wird indirekt schon im TPicture gespeichert. Und war sind alle Bilder-Klassen von TGraphic abgeleitet. Wenn man also mit TPicture ein Bild läd, so wird dynamich die benötigte Klasse erzeugt (class of TGraphic). Das Property Graphic ist also der Klassentyp des Bildes. Wenn du also ein JPEG in ein TPicture lädst so müsste das Graphic-Property vom Typ TJPEGImage sein etc.
@turboPASCAL: Das die Grafik intern als TBitmap gehandelt wird ist falsch. Wenn du mal ein JPEG in ein TPicture lädst und versuchst auf Picture.Bitmap zu zugreifen sollte dir eine AV erscheinen. Wenn TPicture alles als Bitmap handeln würde so wären alphatransparenz im TImage gar nicht möglich was aber eindeutig geht (siehe PNG) |
Re: Welche Grafikart befindet sich TPicture Variable?
Zitat:
Zitat:
Du kannst ja eine TGrafik ja auch mit BitBlt auf einen DC kopieren. Oder irre ich mich in dieser Sache? :gruebel: ...kann mir das leider nicht genauer anschauen, da fehlen mir ein paar Sources. :mrgreen: |
Re: Welche Grafikart befindet sich TPicture Variable?
Zitat:
Delphi-Quellcode:
Wenn du also ein Metafile reingeladen hattest und dann die Eigenschaft Bitmap benutzt, dann wird der ursprüngliche Inhalt verworfen.
{
Graphic - The TGraphic object contained by the TPicture Bitmap - Returns a bitmap. If the contents is not already a bitmap, the contents are thrown away and a blank bitmap is returned. Icon - Returns an icon. If the contents is not already an icon, the contents are thrown away and a blank icon is returned. Metafile - Returns a metafile. If the contents is not already a metafile, the contents are thrown away and a blank metafile is returned. } |
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:49 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz