Autor Beitrag
csigg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Mo 25.07.05 16:29 
Wie kann ich ein TJPEGImage verkleinern??
Ich hab die Qualität herunter gesetzt, wurde jetzt aber noch gern die Masse ändern.
Geht das mit den Standart Komponenten, oder brauch ich da JEDI, o.ä??
Tastaro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 414
Erhaltene Danke: 23



BeitragVerfasst: Mo 25.07.05 16:31 
Die Masse eines Gegenstands stellt man fest, indem man eine Balkenwaage verwendet. Da diese bei einem virtuellen Objekt wie einem JPG-Image zu ziemlich gegen null gehen dürfte, gibt es da nix zu verringern. :-)

Anders ausgedrückt: Was meinst du mit "Masse"?

Beste Grüße
Tastaro
csigg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Mo 25.07.05 16:32 
Sorry, mit Masse war eigentlich Maße gemeint, also Höhe und Breite *g*
Tastaro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 414
Erhaltene Danke: 23



BeitragVerfasst: Mo 25.07.05 16:37 
Schau dir mal die Funktion StretchBlt an. Die arbeitet mit Bitmaps. Also JPG nach BMP konvertieren -> Größe ändern -> BMP nach JPG konvertieren.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
      StretchBlt(oBitmapStretch.canvas.Handle,  // handle of destination device context
                 0,                             // x -coordinate of upper-left corner of dest. rect.
                 0,                             // y-coordinate of upper-left corner of dest. rect.
                 iNewXSize,                     // width of destination rectangle
                 iNewYSize,                     // height of destination rectangle
                 oBitmapOriginal.canvas.Handle, // handle of source device context
                 0,                             // x-coordinate of upper-left corner of source rectangle
                 0,                             // y-coordinate of upper-left corner of source rectangle
                 oBitmapOriginal.Width,         // width of source rectangle
                 oBitmapOriginal.Height,        // height of source rectangle
                 SRCCOPY                        // raster operation code
                );


Beste Grüße
Tastaro
csigg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Mo 25.07.05 16:43 
Wie konvertiere ich das jpg zu einem bmp??
Tastaro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 414
Erhaltene Danke: 23



BeitragVerfasst: Mo 25.07.05 17:09 
Man verwende die Suchfunktion. :-)

Beste Grüße
Tastao
Lossy eX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1048
Erhaltene Danke: 4



BeitragVerfasst: Di 26.07.05 08:34 
Ich persönlich würde nur dann mit StretchBlt wenn es darum geht etwas gestreched zu zeichnen. Bei einem Bild was du wieder irgendwo speichern möchtest würde ich mich mal auf die Suche nache einem Resample Algorithmus machen. Das Ergebniss ist dann um längen Besser als mit StretchBlt.

_________________
Nur die Menschheit ist arrogant genug, um zu glauben sie sei die einzige intelligente Lebensform im All. Wo nicht mal das nachhaltig bewiesen wurde.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Di 26.07.05 09:03 
ausblenden volle Höhe 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:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
{Bildgröße verändern}

procedure TForm1.AnpassenClick(Sender: TObject);
var
  Bitmap1: TBitmap;
  Bitmap2: TBitmap;
begin
  Bitmap1 := TBitmap.Create;
  Bitmap1.LoadFromFile(Edit1.Text);
  Bitmap2 := TBitmap.Create;
  Bitmap2.Width := 350;
  Bitmap2.Height := 350;
  Bitmap2.Canvas.StretchDraw(Rect(0,0,Bitmap2.Width-1,Bitmap2.Height-1),Bitmap1);
  Bitmap2.SaveToFile('./b.bmp');
  Bitmap1.Free;
  Bitmap2.Free;
  Image1.Picture.LoadFromFile('./b.bmp');
end;



procedure TForm1.BildladenClick(Sender: TObject);
begin
OpenPictureDialog1.Execute;
Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
Edit1.Text:=(OpenPictureDialog1.FileName);
end;


{bmp nach jpg}


uses JPEG;
Procedure BmpToJpg(const Filename: String
Quality: TJPEGQualityRange=100);
var 
Bmp: TBitmap; 
Jpg: TJpegImage;
begin
Bmp:=TBitmap.Create;
Jpg:=TJpegImage.Create;
try  
Bmp.LoadFromFile(Filename);  
Jpg.CompressionQuality:=Quality;
  Jpg.Assign(Bmp);
  Jpg.SaveToFile(ChangeFileExt(Filename, '.jpg' ));
finally 
 Jpg.Free;
  Bmp.Free;
end;
end;


{jpg nach bmp}


uses jpeg;
procedure JpegToBmp(const Filename: String);
var 
jpeg: TJPEGImage; 
bmp: TBitmap;begin jpeg:=TJPEGImage.Create; 
try   
jpeg.LoadFromFile(Filename);   
bmp:=TBitmap.Create;  
 try     
bmp.Assign(jpeg);     
bmp.SaveToFile(ChangeFileExt(Filename, '.bmp'));   
finally     
bmp.free;   
end
finally   
jpeg.free; 
end;
end;