Hello,
How should I save a picture (object) to a file?
I have the following kind of code now but the saved picture mostly contains question marks:
var
width,height,bitsperpixel : integer;
ByteCount : integer;
pixels : string;
begin
width:=aObject.Attribute['BitmapWidth'];
height:=aObject.Attribute['BitmapHeight'];
bitsperpixel:=aObject.Attribute['BitsPerComponent'];
ByteCount:=(bitsperpixel * width * height) div 8; // Calculate size (in bytes) of image data
if (bitsperpixel * width * height) mod 8 > 0 then inc(ByteCount);
if bitsperpixel=1 then ByteCount:=ByteCount*2;
SetLength(Pixels, ByteCount);
Pixels:=aObject.Attribute['BitmapData'];
SaveFile('c:\temp.tiff',Pixels);
SetLength(Pixels, 0);
end;
How to save a picture to file
Re: How to save a picture to file
The data that you obtain using the method below are only the scanlines as an uncompressed BMP. You are saving it as a TIF file which is not right. You need to write the BMP header to the file followed by the bitmap data and save the file as .BMP file. We are looking at adding a method to the picture object that would simply save the whole image to a file or a memory stream.
Amyuni Development Team
Efficient and accurate conversion to PDF, XPS, PDF/A and more. Free trials at - https://www.amyuni.com
Efficient and accurate conversion to PDF, XPS, PDF/A and more. Free trials at - https://www.amyuni.com