Autor Beitrag
lemming
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 470

Mac OS 10.3.1
Delphi 6 Pro, Kylix 3
BeitragVerfasst: Mo 22.07.02 16:19 
...kicken, treten, drauf hüpfen. Hauptsache es wird kleiner.

Hi!

Ich habe ein TBitmap das 1240x1000 Pixel gross ist. Wenn ich es mit SaveToFile('c:\test.bmp') speichere ist die Datei 1.3MB gross. Mehr oder weniger, je nach Farbtiefe. Nun will ich es auf 150x120 bringen. Qualitätsverlust ist erlaubt, allerdings darf es nicht nur abgeschnitten werden - also gestretcht werden.

Bei TImage gibt es "Stretch". Wie kann ich das nun bei TBitmap machen?

Danke ciao, lemmi
Alfons-G
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 307

Win XP Prof, Linux, Win 7
D5 Prof, D7 Architect, D2005 Architect, D2007 Architect
BeitragVerfasst: Mo 22.07.02 18:21 
Du brauchst nicht drauf hüpfen :lol:
Das geht mit der Methode StretchDraw von TCanvas.
ausblenden Quelltext
1:
2:
3:
4:
...
MeinRechteck := Rect (0, 0, 150,120);
KleineBitmap.Canvas.StretchDraw (MeinRechteck, GrosseBitmap);
...
Drumherum das Übliche (create, load, save, usw)

:idea:

_________________
Alfons Grünewald
lemming Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 470

Mac OS 10.3.1
Delphi 6 Pro, Kylix 3
BeitragVerfasst: Di 23.07.02 10:32 
Titel: tja, manchmal
...sieht man den Wald vor lauter Bäumen nicht. Danke!
Bayo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: Mi 21.08.02 23:20 
Hi zusammen....

Ich habe das selbe Problem, wie lemming hatte, leider konnte ich es auch mit dem Eintrag von alfons-g nicht lösen!!

Kann mir evtl. jemand sagen, was am folgenden Code falsch ist??

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
var
  bmp: TBitmap;
  bmp2: TBitmap;

begin
  bmp := TBitmap.Create;
  bmp2 := TBitmap.Create;
  try
    bmp.LoadFromFile('D:\test.bmp');
    bmp2.Canvas.StretchDraw(Rect(0, 0, 150, 120), bmp);
    bmp2.SaveToFile('D:\test2.bmp');
  finally
    FreeAndNil(bmp);
    FreeAndNil(bmp2);
  end;


Ich bedanke mich für eure Antworten!!

Grüsse Dominic
lemming Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 470

Mac OS 10.3.1
Delphi 6 Pro, Kylix 3
BeitragVerfasst: Do 22.08.02 08:13 
Du musst vorher die Höhe und Breite von bmp2 angeben.

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
var
  bmp: TBitmap;
  bmp2: TBitmap;

begin
  bmp := TBitmap.Create;
  bmp2 := TBitmap.Create;
  try
    bmp.LoadFromFile('d:\test.bmp');

    bmp2.Width := 150;
    bmp2.Height := 120;

    bmp2.Canvas.StretchDraw(Rect(0, 0, 150, 120), bmp);
    bmp2.SaveToFile('d:\test2.bmp');
  finally
    FreeAndNil(bmp);
    FreeAndNil(bmp2);
  end;
end;