Autor Beitrag
accessViolation
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 68

Win
Delphi 5 Enterpr.
BeitragVerfasst: Do 14.09.06 16:48 
Hallo...

Ich habe als Quelle ein TBitmap und möchte es (z.B.) als TIFF, PCX und PNG abspeichern. Für jedes Format "create" ich ein Objekt der jeweiligen Grafikklasse (XXXimage := TXXXGraphic.Create;) und mache dann XXXimage.Assign(Bitmap). Siehe folgender Code:

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:
function SaveTo(Image: TBitmap): boolean;
var tifImage: TTIFFGraphic;
    pcxImage: TPCXGraphic;
    pngImage: TPNGGraphic;
begin
   try
      tifImage := TTIFFGraphic.Create;
      tifImage.Assign(Image);
      jpgImage.SaveToFile('atif.tif'); // <-- [EDIT] Sorry, es muss natürlich tifImage... heißen [/EDIT]
      result := true;
   except
      result := false;
   end;

   try
      pcxImage := TPCXGraphic.Create;
      pcxImage.Assign(Image);
      pcxImage.SaveToFile('apcx.pcx');
      result := true;
   except
      result := false;
   end;

   try
      pngImage := TPNGGraphic.Create;
      pngImage.Assign(Image);
      pngImage.SaveToFile('apng.png');
      result := true;
   except
      result := false;
   end;
end;



Allerdings ist der Dateiinhalt bei PCX genau der gleiche wie bei PNG.

Ich habe es auch mit BMP (ohne die GraphixEx: einfach Image.SaveToFile) probiert, hier wieder der gleiche Inhalt wie bei PCX mit GraphicEx.

[EDIT] Die Tif-Datei hat jedoch eine Größe von 0 Bytes... [/EDIT]

Was mache ich falsch? Ich vermute, es liegt daran, dass ich mit .Assign immer ein TBitmap zuweise... aber warum ist dann ausgerechnet die TIF-Datei leer?

Wäre schön, wenn mir da jemand weiterhelfen könnte ;)
Viele Grüße
Dietmar
Fraengie
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Mo 25.09.06 11:05 
Titel: gleiches Problem
Hallo Dietmar,

stehe vor dem gleichen Rätsel... bekomme es einfach nicht in den Griff, ein Bitmap als .tif zu speichern. Habe jetzt schon Stunden mit der libtiff verschwendet.
Hast Du inzwischen schon eine Lösung für dein Problem gefunden?

Gruß
Frank