Autor Beitrag
Darth Sitthiander
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 95



BeitragVerfasst: Sa 25.03.06 21:13 
Hallo

Ich habe mal eine Frage bezüglich der Veränderung der grösse von Bitmaps. Ich weiss ja wie das geht, aber wenn ich das bild erst verkleinere und danach wieder vergrössere, dann sieht ja alles pixelig aus. Desshalb habe ich mir gedacht, ich vergrösser/verkleiner einfach das originalbild. Allerdings klappt es miir nicht ganz. Hier der Quelltext:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
function ResizeBmp(bitmp: TBitmap; wid, hei: Integer): Boolean;
var
  TmpBmp: TBitmap;
  ARect: TRect;
begin
  Result := False;
  try
    TmpBmp := TBitmap.Create;
    try
      TmpBmp.Width  := wid;
      TmpBmp.Height := hei;
      ARect := Rect(0,0, wid, hei);
      TmpBmp.Canvas.StretchDraw(ARect, Bitmp);
      bitmp.Assign(TmpBmp);
    finally
      TmpBmp.Free;
    end;
    Result := True;
  except
    Result := False;
  end;
end;


Aufruf:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure Tbb.Einstellungen1Edit1KeyPress(Sender: TObject; var Key: Char);
var
hoehe, breite:string;
begin
if einstellungen1.edit2.text <> '' then
begin
if Key = #13 then
begin
hoehe := einstellungen1.edit1.text;
breite := einstellungen1.edit2.text;
ResizeBmp(openpicturedialog1.filename, image1.Picture.bitmap.Width, strtoint(hoehe));
Key := #0;
end;
end;
end;


Was mache ich genau falsach? Bei mir kommt diese Fehlermeldung:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
[Hinweis] bildb.pas(228): Auf 'Gr' zugewiesener Wert wird niemals benutzt
[Hinweis] bildb.pas(398): Auf 'ResizeBmp' zugewiesener Wert wird niemals benutzt
[Fehler] bildb.pas(669): Inkompatible Typen: 'TBitmap' und 'TFileName'
[Fataler Fehler] bildb.pas(8): Verwendete Unit 'bildb' kann nicht compiliert werden


Aber ich kann damit nichts anfangen. Danke für eure Hilfe.
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 25.03.06 21:16 
Du übergibst der Funktion im Aufruf einen TFilename,aber die Funktion erwartet als ersten Paramter TBitmap.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Darth Sitthiander Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 95



BeitragVerfasst: Sa 25.03.06 21:17 
Kann man da nichts machen?
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 25.03.06 21:20 
Ja, kann man ;)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure Tbb.Einstellungen1Edit1KeyPress(Sender: TObject; var Key: Char);
var
hoehe, breite:string; bitmap:TBitmap;
begin
  if einstellungen1.edit2.text <> '' then
  begin
    if Key = #13 then
    begin
      hoehe := einstellungen1.edit1.text;
      breite := einstellungen1.edit2.text;
      bitmap.loadfromfile(openpicturedialog1.filename);
      ResizeBmp(bitmap, image1.Picture.bitmap.Width,       strtoint(hoehe));
    Key := #0;
    end;
  end;
end;

Ich habe nebenbei den Code übersichtlicher formatiert ;)

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Darth Sitthiander Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 95



BeitragVerfasst: Sa 25.03.06 21:25 
Danke vielmals. Da hätt ich eigentlich selber drauf kommen müssen :D :autsch: :autsch: :autsch:
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 25.03.06 21:27 
user profile iconDarth Sitthiander hat folgendes geschrieben:
Danke vielmals. Da hätt ich eigentlich selber drauf kommen müssen :D :autsch: :autsch: :autsch:

Ja also wirklich mal! :mahn: :mrgreen:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot