Autor Beitrag
benjamin_200
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mi 24.09.08 15:08 
Hallihallo,

ich bin erst ganz neu in der Welt mit Delphi.

Wie füge ich denn Bilder ein, bzw was ist Loadfromfile???:)

vielen dank


Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Mi 24.09.2008 um 16:38
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mi 24.09.08 15:11 
Für statische Bilder eignet sich die Image-Komponente (Palette Additional). LoadFromFile ist eine Methode der Klasse TImage. ;)
ausblenden Delphi-Quelltext
1:
Image.LoadFromFile('Pfad des Bildes');					
benjamin_200 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Fr 26.09.08 21:49 
aber wo schreibe ich das dann rein?
und wie gebe ich den den Pfad an?
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Fr 26.09.08 21:51 
user profile iconbenjamin_200 hat folgendes geschrieben:
aber wo schreibe ich das dann rein?
und wie gebe ich den den Pfad an?

Da, wo das Bild geladen werden soll.
Am besten komplett, mit Laufwerk und allen Verzeichnissen + Dateiname.

Edit: Dafür brauchst du natürlich ein TImage auf deinem Formular.

_________________
PROGRAMMER: A device for converting coffee into software.
benjamin_200 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mo 29.09.08 12:08 
mh...

wo hängts dabei?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Image1Click(Sender: TObject);
begin
  image1.LoadFromFile( 'C:\Dokumente und Einstellungen\joe\Eigene Dateien\am_2')
end;


er meckert mit der fehlermeldung undeclared identifier : loadfromfile

Vielen dank schonma

Moderiert von user profile iconTino: Delphi-Tags hinzugefügt
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 29.09.08 12:12 
ausblenden Delphi-Quelltext
1:
Image1.Picture.LoadFromFile(...);					
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Mo 29.09.08 14:10 
Und ich gehe mal davon aus, dass die Datei am_2.bmp oder am_2.jpg oder so heißt, das müsstest du dann entsprechend hinschreiben.
benjamin_200 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mo 29.09.08 15:22 
sorry dass ich damit weiter nerve, aber läuft nach wie vor nich.
ausblenden Delphi-Quelltext
1:
image1.Picture.loadfromfile(C:\Dokumente und Einstellungen\joe\Eigene Dateien\am_2.jpg);					

er meckert mit undeclared identifier C:
missing operator or semicolon
und illegal character in input file

Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mo 29.09.08 15:29 
Du musst den Pfad auch als String übergeben, d.h. in ' ' Hochkommas setzen.

ausblenden Delphi-Quelltext
1:
image1.Picture.loadfromfile('C:\Dokumente und Einstellungen\joe\Eigene Dateien\am_2.jpg');					

Aber Achtung, so wie es jetzt dort steht, wird es mit hoher Wahrscheinlichkeit nur auf deinem Computer funktionieren. :zwinker:
platzwart
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1054
Erhaltene Danke: 78

Win 7, Ubuntu 9.10
Delphi 2007 Pro, C++, Qt
BeitragVerfasst: Mo 29.09.08 18:58 
und jpegs werden nicht out-of-the-box unterstützt. musst also noch die entsprechende unit hinzufügen...
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Mo 29.09.08 19:20 
(jpeg). Genauso wie PNG. :zwinker:
benjamin_200 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mo 29.09.08 19:29 
out of box sagt mir leider nichts.
Ich hab aus der Add Leiste ein IMage eingefügt und hab dann jetzt beim Buttonclick ein Bild versucht reinzuladen.

procedure TForm1.Button1Click(Sender: TObject);
begin

image1.picture.LoadFromFile('C:\Dokumente und Einstellungen\joe\Eigene Dateien\am_2');
end;

ZUmindest startet er das Progrämmchen jetzt schonma, aber beim button-click stoppt es dann und gibt mir ne fehlermeldung:

Project xxxx raised exception class yyyyy with message 'zzzzzz'.

Process stopped. Use Step or Run to continue ( hab ich so aus der hilfe kopiert weil ichs nich abschreiben wollte^^)

was is falsch?
Timosch
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1314

Debian Squeeze, Win 7 Prof.
D7 Pers
BeitragVerfasst: Mo 29.09.08 19:35 
Du musst schon lesen was man hier schreibt. Die Endung fehlt. Und ggf. noch die Unit jpeg oben unter uses hinten dranhängen.
Out of the box heißt soviel wie ohne große Vorkehrungen, bzw. in diesem Fall ohne zusätzliche Units oder Komponenten.
Übrigens: Wieso legst du das Bild nicht in den Ordner des Programms? So kannst nur du das Programm ausführen.
Und nochwas: Die Meldung "...raised exception class yyyyy" ist nicht gerade aussagekräftig. Du solltest selbstverständlich schreiben, was du genau statt yyyyy steht, denn genau das ist die Ursache. Alles andere ist bloß ein allgemeiner Hinweis und egal. yyyyy ist die Ursache. In dem Fall wusste ich nur, worans wahrscheinlich liegt, weil der Fall recht offensichtlich ist.

_________________
If liberty means anything at all, it means the right to tell people what they do not want to hear. - George Orwell


Zuletzt bearbeitet von Timosch am Mo 29.09.08 19:39, insgesamt 3-mal bearbeitet
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Mo 29.09.08 19:36 
Wie wär's mit der Exception selbst - Ctrl + C wenn die Exception-Meldung erscheint? Und hast du dir den Thread mal durchgelesen? Insbesondere meinen Tipp, dass das Teil eventuell am_2.jpg heißt, oder am_2.bmp, oder am_2.png? -> DATEIENDUNG!!! Musst mal Googlen, die kann man sich auch irgendwie anzeigen lassen, entweder in den Explorer-Optionen oder in der Systemsteuerung (tendiere zu Systemsteuerung; bin mir aber nicht sicher).

EDIT: Mist, da war jemand schneller. :P
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Mo 29.09.08 19:45 
user profile iconbenjamin_200 hat folgendes geschrieben:
with message 'zzzzzz'

Exception heißt so viel wie "Ausnahme", frei übersetzt hier "Fehler". Welcher Fehler aufgetreten ist, wäre aber schon interessant :lol:

Vermutlich existiert hinter deinem Pfad einfach kein Bild; du hast einen Tippfehler, die falsche Endung, etc..

Mit der Art, wie dir das hier garade gezeigt wird, bin ich aber sowieso nicht einverstanden: Es sollte ja nicht nur auf deinem, sondern auf jedem PC funktionieren. Und dazu sind relative Pfade notwendig.

Bei einem statischen Bild würde das wohl im selben Ordner liegen wie deine Exe.

Klick mal auf dein Formular(nicht auf's Image, sondern auf die Form dahinter, am besten auf den Rahmen. Unter "Events" im Object Inspector platzierst du folgenden Code; er wird dann beim Erzeugen des Formulars, beim Start des Programms, ausgeführt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
type
  TForm1 = class(TForm)
    {..}
  end;

const
  BildOrdner = 'Bilder\';
  Image1PicPfad = 'Badewannenente.bmp';


var
  Fomr1: TForm1;

implementation

procedure TForm1.FormCreate(Sender: TObject);
var
  ProgrammOrdner: String;
beign
  ProgrammOrdner := ExtractFilePath(Application.ExeName);
  Image1.LoadFromFile(ProgrammOrdner + BildOrdner + Image1PicPfad);  
end;


Der Quelltext kommt per Edit, ich beantworte erstmal die Frage aus dem orrangefarbenden Kasten, die mich da so schön anleuchtet: Wenn du eine beliebigen Ordner öffnest, kannst du unter "Extras/Ordneroptionen" ein Häkchen in einer CheckBox setzen, durch das dann stets auch die Endung angezeigt wird.

Edit: Vielleicht solltest du dir mal diesen Crashkurs von Christian S. ansehen ;)

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)


Zuletzt bearbeitet von Hidden am Mo 29.09.08 19:58, insgesamt 3-mal bearbeitet
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Mo 29.09.08 19:47 
Was du brauchst ist ein Application.ExeName + 'am_2.jpg'. :wink:
Timosch
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1314

Debian Squeeze, Win 7 Prof.
D7 Pers
BeitragVerfasst: Mo 29.09.08 20:04 
user profile iconJakob_Ullmann hat folgendes geschrieben:
Was du brauchst ist ein Application.ExeName + 'am_2.jpg'. :wink:

Käse. :mrgreen: Da käme dann sowas raus wie programm.exe\am_2.jpg. Du hast wohl ExtractFilePath(Application.Exename(xyz)) gemeint. Aber zunächstmal sollte man ihn die Endung hinzufügen lassen.

Endungen kann man in den Ordneroptionen im Explorer anzeigen lassen, aber jemand, der die ausblenden lässt, ist sowieso kein ernstzunehmender Computernutzer...

_________________
If liberty means anything at all, it means the right to tell people what they do not want to hear. - George Orwell
benjamin_200 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mo 29.09.08 20:40 
jop vielen dank an alle.
Ich werde mal den Crashkurs machen, das is wohl besser;-)
benjamin_200 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mi 01.10.08 13:42 
Ich erdreiste mich mal nochmal zu fragen.

Ich hab den Crashkurs gemacht und zumindest weite Teile auch verstanden aber von Bildern war da leider wenig die Rede.

ICh hoffe mal ich hab alles vorher geschrieben beachtet aber trotzdem Fehlermeldungen.
procedure TForm1.Button1Click(Sender: TObject);
begin
image1.picture.loadfromfile(\programmieren + jöri_1.jpg);
end;

end.

erste fehlermeldung : illegal character in input file : "\"
zweite: undeclared identifier : " zeichen kenn ich nich...sieht aus wien umgedrehtes Ausrufezeichen!"
vielen dank falls noch jemand bock hat sich mit mir rumzuschlagen
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 01.10.08 13:46 
Schau nochmal hier