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:
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'); 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