Autor Beitrag
FrEaKY
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 235


D7
BeitragVerfasst: Do 17.03.05 21:23 
Moin,
hab da nen kleines Prob beim ändern der Farbtiefe einens Jpg. Und zwar mach ich ein server-client station wo der der client vom server regelmäßig in kurzen abständen screenshots kriegt. Also eine fernkontrolle. Dafür sollen die Bilder möglichst klein sein damit ich in dem niedirgsten intervall verschicken kann. Aber wenn ich jez hier die Farbtiefe änder is das jpg immer 0 KB groß :(
hierr mein quellcode:
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:
function Bmp2Jpg(const ABmp: TBitmap; AQuality: Integer): TJPEGImage;
type
 TJPEGQualityRange = 1..100;
var bmp : TBitmap;
   Jpg : TJpegImage;
begin
 bmp := TBitmap.Create;
 jpg := TJpegImage.Create;
 try
   Jpg.CompressionQuality := AQuality;

   Jpg.Assign(Abmp);

   jpg.PixelFormat := jf8bit;
   Jpg.SaveToFile ( ChangeFileExt('C:/Rcon', '.jpg' ));
 finally
   jpg.Free;
   bmp.Free; 
 end;
end;

procedure TForm1.Button1Click(Sender: TObject);
  var 
  Bitmap: TBitmap;
  DeskWh: HWND; 
  DeskDC: HDC; 
  DeskRc: TRect; 
begin

    DeskWh := GetDesktopWindow; 
    DeskDC := GetDC(DeskWh);
    GetWindowRect(DeskWh, DeskRc); 
    Bitmap := TBitmap.Create;
    try 
       Bitmap.Width  := DeskRc.Right  - DeskRc.Left; 
       Bitmap.Height := DeskRc.Bottom - DeskRc.Top; 
       BitBlt(Bitmap.Canvas.Handle, 0, 0, Bitmap.Width, Bitmap.Height, 
       DeskDC, 0, 0, SRCCOPY);

       bmp2jpg(bitmap,50);

    finally
       ReleaseDC(DeskWh, DeskDC);
       bitmap.Free;
    end;
end;

end.
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: So 20.03.05 21:15 
mal pixelformat vor assign versucht (weiß net obs daran liegen könnte)

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
Brueggendiek
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 304

Win 98, Win98SE, Win XP Home
D5 Std
BeitragVerfasst: So 20.03.05 21:23 
Hallo!

Ist bei der Problemstellung nicht ein riesengroßer Denkfehler drin?

AFAIK hat JPG immer eine Farbtiefe von 24 Bit.

Wenn die Datei kleiner werden soll, kan man das nur über die Kompression erreichen. JPG ist ja eine verlustbehaftete Kompresion. Je stärker die Kompression, desto kleiner die Datei und schlechter das Ergebnis.

Gruß

Dietmar Brügggendiek
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: So 20.03.05 21:25 
denk mla nicht das nen TJpegImage sonst pixelformat unterstützt so viel ich weiß kann ein jpg auch ne 8 bit farbtiefe haben

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
Neidhard von Reuental
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 268

XP
BDS 2006 Prof
BeitragVerfasst: So 20.03.05 21:32 
die sind dann aber meines wissens im graustufenformat.
ist auch fraglich ob das die normale jpeg-lib unterstützt