Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi Bilder aus ImageList auswählen (https://www.delphipraxis.net/69621-bilder-aus-imagelist-auswaehlen.html)

Gehstock 18. Mai 2006 01:24

Re: Bilder aus ImageList auswählen
 
hab in der combobox erstmal von 0-10 Tstrings erstellt
in der imagelist sind 57 Bilder (die später über ihre namen in der ComboBox auswählbar sind)mach ich aber später
also wenn ich jetzt in der combobox 1 auswähle wird bild 2 angezeigt wähle ich jetzt die 2 bleibt bild 2 aber bestehen

Delphi-Quellcode:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ImgList, StdCtrls, ExtCtrls;

type
  TForm2 = class(TForm)
    Image1: TImage;
    ComboBox1: TComboBox;
    ImageList1: TImageList;
    procedure ComboBox1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}




procedure getimage(imglst:TimageList; Id:Integer;bitmap:tbitmap);
var bit : TBitmap;
begin
  bit := TBitmap.Create;
  try
    imglst.GetBitmap(id, Bit);
    bitmap.Assign(bit);
  finally
    FreeAndNil(Bit);
  end;
end;


procedure TForm2.ComboBox1Change(Sender: TObject);

var bitmap : tbitmap;
begin
bitmap := tbitmap.create;
getimage(ImageList1,0,bitmap);
Image1.picture.bitmap.assign(bitmap);
freeandnil(bitmap);

  end;

end.

pacman1986 18. Mai 2006 01:30

Re: Bilder aus ImageList auswählen
 
Zitat:

Zitat von Gehstock
Delphi-Quellcode:
procedure TForm2.ComboBox1Change(Sender: TObject);

var bitmap : tbitmap;
begin
bitmap := tbitmap.create;
getimage(ImageList1,0,bitmap);
Image1.picture.bitmap.assign(bitmap);
freeandnil(bitmap);

end;
end.

Wie schon gesagt für ein anders bild musst du einen anderen parameter übergeben und dass tust du nicht.
Richtig wäre:


Delphi-Quellcode:
procedure TForm2.ComboBox1Change(Sender: TObject);
var bitmap : tbitmap;
begin
  bitmap := tbitmap.create;
  getimage(ImageList1,combobox1.itemindex,bitmap);
  Image1.picture.bitmap.assign(bitmap);
  freeandnil(bitmap);
end;

end.
Ntürlich ist das sehr code spezifisch aber bei denem sollte es so wie ich es verstanden habe gehen ...

Delphi-Quellcode:
getimage(ImageList1,combobox1.itemindex,bitmap);
das musst du ändern

Gehstock 18. Mai 2006 01:35

Re: Bilder aus ImageList auswählen
 
ganau so jetzt klappt es
konnte über einzelne buttons auch unterschiedliche bilder anzeigen war mir also schonmal klar das es an der combo box lag

Danke nochmal!! Hast du Nachtschicht im Forum? Bereitschaftsdienst?

pacman1986 18. Mai 2006 01:36

Re: Bilder aus ImageList auswählen
 
Nein Langeweile ^^

Gehstock 3. Jun 2006 18:19

Re: Bilder aus ImageList auswählen
 
Und wie bekomm ich Jpeg´s in die imagelist die BMP´s blähen das prog so auf
mit jpeg unter uses brigts nichts
oder brauch ich was anderes

Klaus01 3. Jun 2006 18:42

Re: Bilder aus ImageList auswählen
 
Vielleicht magst Du dir den Thread hier anschauen -> http://www.experts-exchange.com/Prog..._21504180.html

Grüße Klaus

Gehstock 3. Jun 2006 20:55

Re: Bilder aus ImageList auswählen
 
Gibts auch was wo ich für die antwort nicht 10 Dollar hinlegen muss

ManuMF 4. Jun 2006 11:25

Re: Bilder aus ImageList auswählen
 
Hallo,

warum so kompliziert? :cyclops:

Bei mir funktioniert es auch so (für Bitmaps):
Delphi-Quellcode:
ImageList1.GetBitmap(ComboBox1.ItemIndex, Image1.Picture.Bitmap);
// auch wieder in ComboBox.onChange
ohne umständliche Funktion.

Das Erneuern klappt bei mir mit
Delphi-Quellcode:
Image1.Refresh;
Für Jpeg-Bilder kann ich dir übrigens die Hier im Forum suchenG32-Library empfehlen.

Gruß,
ManuMF


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:16 Uhr.
Seite 2 von 2     12   

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