Autor Beitrag
110022
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 287

XP SP2
Delphi 7
BeitragVerfasst: Mi 25.02.09 18:29 
Hallo zusammen.

Als wie es im titel steht geht es darum, dass ein paar bilder beim Start geladen werdn sollen.

Mittlerweile hab ich auch erfahren dass es über eine Klasse TBitmap geht, aber ich habe keine Ahnung wie man diese einbindet und dann die Bilder daraus nutzt.
Vllt könnt ihr mir ja helfen.

110022
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 25.02.09 18:33 
Erstens brauchst du eine Variable bzw. ein Feld vom Typ TBitmap. Das kommt z.B. oben unter private hin.
ausblenden Delphi-Quelltext
1:
2:
private
  MyImage: TBitmap;
In OnCreate des Formulars erzeugst du das Objekt und lädst die Datei:
ausblenden Delphi-Quelltext
1:
2:
MyImage := TBitmap.Create;
MyImage.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'MeinBild.bmp');
Dann in OnDestroy entfernst du das Objekt wieder aus dem Speicher mit Free.

Jetzt kannst du deine Bitmap im Programm irgendwo verwenden. Zum Beispiel in ein Image zeichnen mit ImageX.Picture.Bitmap.Canvas.Draw oder in das Image legen mit ImageX.Picture.Bitmap.Assign, z.B. in OnMouseEnter / OnMouseLeave.
110022 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 287

XP SP2
Delphi 7
BeitragVerfasst: Mi 25.02.09 18:35 
Und wenn es mehrere Bilder werden sollen?
Reihe ich die dann untereinander oder wie?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 25.02.09 18:43 
Wenn die Anzahl klein ist, ja.

Wenn es mehr sind, dann bietet sich eher eine TImageList oder ein Array an, wobei man dann aber auch auf die Speichernutzung aufpassen muss, wenn es zu viele werden.

Durch die Einbindung der Unit Jpeg kann man ja auch Jpegs benutzen, das ginge mit einer TImageList nicht.
110022 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 287

XP SP2
Delphi 7
BeitragVerfasst: Mi 25.02.09 19:06 
Aha, wie geht denn eine TImageList?^^

Es sind 6 Bilder die Geladen werden müssen
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 25.02.09 19:15 
TImageList aufs Formular, Bilder hinzufügen, dann per Code benutzen.

Aber bei 6 Bildern sind 6 TBitmaps wohl die einfachste Lösung. ;-)
110022 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 287

XP SP2
Delphi 7
BeitragVerfasst: Mi 25.02.09 19:17 
OK, danke.
Werds mal versuchen^^



Und Wie füge ich das ganze ein?
Image1.Picture.Bitmap.Canvas.Draw(////Was kommt hier rein?\\\\)
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 25.02.09 19:40 
x und y Koordinate, an der gezeichnet werden soll, und die Bitmap. Das steht aber auch so in der Hilfe, siehe Zitat und Link...
Delphi-Hilfe hat folgendes geschrieben:
Zeichnet am Punkt (X,Y) der Zeichenfläche die im Parameter Graphic angegebene Grafik.
Wenn das ganze Bild geändert werden soll, dann geht das mit Assign am einfachsten.
110022 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 287

XP SP2
Delphi 7
BeitragVerfasst: Mi 25.02.09 19:43 
Und wie geht das dann mit assign??
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 25.02.09 19:52 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
oder in das Image legen mit ImageX.Picture.Bitmap.Assign, z.B. in OnMouseEnter / OnMouseLeave.
Oder nur ImageX.Picture.Assign, sollte beides gehen, letzteres ist vielleicht noch besser.
110022 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 287

XP SP2
Delphi 7
BeitragVerfasst: Mi 25.02.09 19:55 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
oder in das Image legen mit ImageX.Picture.Bitmap.Assign, z.B. in OnMouseEnter / OnMouseLeave.
Oder nur ImageX.Picture.Assign, sollte beides gehen, letzteres ist vielleicht noch besser.

Aber wie sieht das dann fertig aus?

So ja wohl nicht...
Image1.Picture.Assign('Bild.bmp');
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 25.02.09 20:09 
Erstens würde da der Pfad fehlen, nur 'Bild.bmp' funktioniert nur zufällig! Siehe oben und hier:
www.delphi-library.d...ewtopic.php?p=499701

Zweitens willst du dein Bild ja aus der TBitmap-Variablen laden und nicht aus der Datei...
Also gib deine Variable auch an als Parameter statt deinem Bilddateinamen.
ausblenden Delphi-Quelltext
1:
Image1.Picture.Assign(MyImage);					
110022 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 287

XP SP2
Delphi 7
BeitragVerfasst: Mi 25.02.09 20:26 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
Erstens würde da der Pfad fehlen, nur 'Bild.bmp' funktioniert nur zufällig! Siehe oben und hier:
www.delphi-library.d...ewtopic.php?p=499701

Zweitens willst du dein Bild ja aus der TBitmap-Variablen laden und nicht aus der Datei...
Also gib deine Variable auch an als Parameter statt deinem Bilddateinamen.
ausblenden Delphi-Quelltext
1:
Image1.Picture.Assign(MyImage);					

Aber was kommt dahin wenns mehrere Dateien sind, so kann der prog ja nicht wissen welche da rein soll

Oder kommt jedes Bild in eine neue TBitmap?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 25.02.09 20:48 
user profile icon110022 hat folgendes geschrieben Zum zitierten Posting springen:
Oder kommt jedes Bild in eine neue TBitmap?
Ja, klar.
110022 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 287

XP SP2
Delphi 7
BeitragVerfasst: Fr 27.02.09 22:57 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
user profile icon110022 hat folgendes geschrieben Zum zitierten Posting springen:
Oder kommt jedes Bild in eine neue TBitmap?
Ja, klar.


jetzt habe ich ne andere frage, ich versuche mich gerade an einer Bedingung, aber ich weiß nicht wie ich das machen soll

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
begin
  if image1.Picture= then
  begin
    mediaplayer1.stop;
    mediaplayer1.Position:=0;
    Image5.Picture.Assign(saus);;
  end
  else
  if image1.Picture= then
  begin
    mediaplayer1.play;
    Image5.Picture.Assign(sein);
  end;
end;

Da liegt mein problem
Nur die Bedingung mit dem Bild ist das Problem.


HAT SICH ERLEDIGT
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 27.02.09 23:04 
Du solltest lieber den Status des MediaPlayers abfragen, ansonsten kannst du auch einen Wert in Image5.Tag speichern. Zum Beispiel 0 für aus und 1 für an.

user profile icon110022 hat folgendes geschrieben Zum zitierten Posting springen:
HAT SICH ERLEDIGT
Das ging ja schnell. :lol:
110022 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 287

XP SP2
Delphi 7
BeitragVerfasst: Fr 27.02.09 23:06 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
Du solltest lieber den Status des MediaPlayers abfragen, ansonsten kannst du auch einen Wert in Image5.Tag speichern. Zum Beispiel 0 für aus und 1 für an.

user profile icon110022 hat folgendes geschrieben Zum zitierten Posting springen:
HAT SICH ERLEDIGT
Das ging ja schnell. :lol:

Wie denn das?
Es geht ja nach den Bildern, es kommt ja auf die Bilder an was passiert

Das erledigt bezog sich auf eine Meldung die probleme gemacht hat



Achso, habs hinbekommen, das klappt wunderbar^^
Danke