Autor Beitrag
TimKellner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 73

Win XP Pro
Delphi 7 Enterprise, RAD Studio
BeitragVerfasst: So 23.03.08 19:50 
Hallo ich wollte ein bild von belibiger größe in das Format 640x480 auflösen. doch die funktion s.u. speichert das bild nicht ab. Weis jmd vielleit etwas woran es liegen könnte?

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:
23:
24:
25:
26:
27:
function TForm1.ResizeJPG(FileName, NewFileName: String; NewWidth,
  NewHeight: Integer): String;
var RBit, Bit: TBitmap;
  JPG: TJPEGImage;
begin
  Bit:=TBitmap.Create;
  RBit:=TBitmap.Create;
  JPG:=TJPEGImage.Create;
  JPG.LoadFromFile(FileName);
  Bit.Assign(JPG);
  RBit.Width:=NewWidth;
  RBit.Height:=NewHeight;
  RBit.Canvas.StretchDraw(Rect(0,0,NewWidth,NewHeight),Bit);
  JPG.Assign(RBit);
  JPG.SaveToFile(FileName);
  JPG.Free;
  RBit.Free;
  Bit.Free;
  Result := 'OK';
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
OpenPictureDialog1.Execute;
SavePictureDialog1.Execute;
ResizeJPG(OpenPictureDialog1.FileName, SavePictureDialog1.FileName, 640480);
end;
nagel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 708

Win7, Ubuntu 10.10

BeitragVerfasst: So 23.03.08 20:24 
Ich denke es müsste JPG.SaveToFile(NewFileName); heißen.