Autor Beitrag
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Di 20.09.05 11:12 
Hallo Leute Ich hab da mal eine Frage wie man das Lösen könnte.
Hab mal die Umwandlung von Bmp zu Jpg als Funktion geschrieben, weil Ich die im Programm des öfteren brauch und wollt mir damit arbeit ersparen.
Funktioniert auch soweit.
Jetzt zu meinen Problem.
Wie könnte Ich die Qualitaet als zweiten Parameter in meiner Funktion unterbringen.
Weil Qualitaet ist ja Integer geht das irgendwie zu Realisieren.

zB. BmpToJpg('Bild'),(Qualitaet);

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:
function BmpToJpg(Bild: String):String;
var
 Jpg : TJpegimage;
 Bmp : TBitmap;
 Qualitaet:Integer;
 begin
  try
   Qualitaet:=100;
   Bmp := Tbitmap.create;
   Jpg := TJpegimage.create;
   Bmp.loadfromfile(Bild+'.bmp');
   Jpg.assign(Bmp);
   Jpg.CompressionQuality := Qualitaet;
   Jpg.compress;
   Jpg.savetofile(Bild+'.jpg');
   DeleteFile(Bild+'.bmp')
  finally
   jpg.free;
   bmp.free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  BmpToJpg('test');
end;
MisterBum
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 107



BeitragVerfasst: Di 20.09.05 11:21 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
function BmpToJpg(Bild: String; Qualitaet: integer):String;
begin
....
end;


Aufruf:
ausblenden Delphi-Quelltext
1:
BmpToJpg('test', 10);					
Blackheart666 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Di 20.09.05 11:29 
@MisterBum Vielen Dank genau so hat Ich das gemeint.
Blackheart666 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Di 20.09.05 22:19 
Hallo.
Abgesehen davon das es fuktioniert hätte Ich doch noch eine Frage zu meiner Function.
Delphi sagt mir ja zum Bsp. das, wenn Ich was falsch mache Parameter erwartet und... gefunden.
Zum Anfang war Mir das klar das Ich nur einen String brauchte und es kam auch keine Fehlermeldung.
Zum zweiten wo Ich meine Probleme hatte mit Integer ist Mir jetzt auch klar.
Was Ich jetzt nicht ganz verstehe ist das String zum Ende.
Wird damit die ganze Function ansich das (BmpToJpg) als String angesehen ?
Deswegen hatte Ich das Problem mit dem Einbinden des
Integer.
Würde Mich mal Interessieren, proge zwar schon eine ganze Weile aber würde mir mal gerne etwas sauberen Code angewöhnen wollen zb. durch Functionen und Prozeduren.