Autor Beitrag
Crazy K
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 26.03.03 12:27 
Hallo, ich wäre äuch sehr dankbar, wenn ihr mir bei dem Problem hefen könntet: Ich will ein Picture in ein TImage laden, das funzt auch gut. Aber das Bild muss mit einer festen Größe geladen werden. nämlich 512 * 512 Pixel. Ich habe bisher folgenden Code. Vielleicht kann mir jemand schreiben, wie ich das auf die feste Größe bekomme. Ich habe hier schon ein bisschen im Forum nach so etwas gesucht habe aber bisher nichts gefunden

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
var
picture: TPicture;
bitmap: TBitmap;

begin
picture := TPicture.Create;
//bitmap := Tbitmap.Create;
if OpenDialog1.Execute then
    begin
    //bitmap.LoadFromFile(OpenDialog1.FileName);
    picture.LoadFromFile(OpenDialog1.FileName);
    Image1.Picture := picture;
    //Image1.Canvas.Draw(0,0,bitmap);
    //bitmap.Free;
    end;

end;
Nightmare_82
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 260



BeitragVerfasst: Mi 26.03.03 13:52 
ausblenden Quelltext
1:
2:
3:
Image1.Width:= 512;
Image1.Height:= 512;
Image1.Stretch:= true;


soweit ich weiß, hab grad kein Delphi da.


Zuletzt bearbeitet von Nightmare_82 am Mi 26.03.03 14:05, insgesamt 2-mal bearbeitet
Teutobod
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 55



BeitragVerfasst: Mi 26.03.03 14:03 
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
var bitmap : TBitmap;
    arect  : TRect;

begin
  if OpenDialog1.Execute then
  begin
    bitmap := Tbitmap.Create;
    bitmap.LoadFromFile(OpenDialog1.FileName);
    aRect.Left   := 0;
    aRect.Top    := 0;
    aRect.Right  := 512;
    aRect.Bottom := 512;
    image1.Canvas.StretchDraw(aRect, bitmap);
    bitmap.free;
  end;


und halt die image größe einstellen
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Mi 26.03.03 14:18 
anstatt dir ne TRect variable zu machen, kannste auch einfach dass machen:
ausblenden Quelltext
1:
image1.Canvas.StretchDraw(Rect(0,0,512,512), bitmap);					

bin mir aber nicht 100% sicher, könnte sein, dass du anstatt Rect Trect schreiben musst... :? :wink:
Teutobod
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 55



BeitragVerfasst: Mi 26.03.03 14:23 
Zitat:
bin mir aber nicht 100% sicher, könnte sein, dass du anstatt Rect Trect schreiben musst...


geht auch nur mit rect
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Mi 26.03.03 14:30 
wahrscheinlich gehts nur mit rect...
aber da ich hier am Comp kein Delphi habe konnte ich es nicht testen... :wink:
Teutobod
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 55



BeitragVerfasst: Mi 26.03.03 14:57 
sag ich ja, geht auch nur mit rect :lol:
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Mi 26.03.03 17:31 
mein ich doch
:mrgreen: :mrgreen: :mrgreen:
Crazy K Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 26.03.03 17:58 
Vielen dank für die schnellen Antworten. Klappt super!
Popov
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1655
Erhaltene Danke: 13

WinXP Prof.
Bei Kleinigkeiten D3Pro, bei größeren Sachen D6Pro oder D7
BeitragVerfasst: Di 22.04.03 15:03 
Übrigens, zum laden einer Bitmap im eine TImage gehe ich immer direkt über Bitmap:

So nicht:

ausblenden Quelltext
1:
Image1.Picture.LoadFromFile('c:\a.bmp');					


So ist besser:

ausblenden Quelltext
1:
Image1.Picture.Bitmap.LoadFromFile('c:\a.bmp');					


Der Unterschied liegt hier im Detail. Bitmap.LoadFromFile ist nur zum laden von Bitmaps mit der Endung .bmp. Picture.LoadFromFile ist zum laden verschiedene Formate (.wmf, .bmp, usw.). Vielleicht deshalb reagiert die erste Variante Alergisch auf kleinere Fehler. Das hier führt z.B. zu einer Fehlermeldung:

ausblenden Quelltext
1:
Image1.Picture.LoadFromFile('c:\a.bmp ');					


Dabei ist es nur ein Leerzeichen zuviel hinter bmp. Anscheinend wird es aber als Teil der Endung angesehen.

_________________
Popov