Autor Beitrag
delphiprogrammierer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 53



BeitragVerfasst: Di 18.11.08 11:31 
Hallo,

ich stehe hier völlig auf dem Schlauch. Ich möchte eine TListview mit JPEG Dateien füllen. Leider finde ich keinerlei Informationen darüber. Wenn ich der TImageList mit

ausblenden Delphi-Quelltext
1:
2:
Image1.Picture.LoadFromFile( 'test.jpg' );
ImageList1.Add( Image1.Picture.Bitmap , Nil );


ein JPEG als Bitmap hinzufüge bekomme ich die Fehlermeldung

"Inavlid Image Size"

Bitte um Hilfe :)

Danke

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Di 18.11.08 12:42 
JPG hat kein Bitmap sondern Grapics.

vieleicht kannst Du folgendes brauchen/umbauen?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
var
  img:TJPEGImage;
  bmp:TBitmap;
begin
  if od.Execute then
    begin
    img:=TJPEGImage.Create;
    bmp:=TBitmap.Create;
    try
     img.LoadFromFile(od.Filename );
    bmp.Width := ImageList1.Width;
    bmp.height := ImageList1.height;
    bmp.Canvas.StretchDraw(Rect(0,0,bmp.Width,bmp.Height),img);
    ImageList1.Add( bmp , Nil );
    finally
    img.Free;
    bmp.Free;
    end;
    end;
    Action1.ImageIndex := ImageList1.Count - 1;
end;


www.explido-software.de

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
delphiprogrammierer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 53



BeitragVerfasst: Di 18.11.08 12:46 
Hab das jetzt so gelöst,

in der OnCustomDrawItem

ausblenden Delphi-Quelltext
1:
2:
Rect := Item.DisplayRect( drIcon );
Sender.Canvas.StretchDraw( Rect, Image1.Picture.Graphic );


Danke, und schon habe ich das nächste Problem. Wenn ich das Form1 in der Grösse zur Laufzeit ändere, bleiben die Bildspalten gleich und ich muss scrollen. Ich möchte aber, dass sich die Anzahl der Spalten entsprechend der neuen Grösse anpasst.

In OnResize der ListView könnte ich darauf reagieren, aber wie ...


Danke

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt