How to save a picture to file

The PDF Creator enables you to create secure PDF documents and to view, print and process existing PDF documents.
If you have any questions about the installation and usage of the PDF Creator please post them here.
Post Reply
calle
Posts: 6
Joined: Tue Nov 04 2008

How to save a picture to file

Post by calle »

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;
Devteam
Posts: 119
Joined: Fri Oct 14 2005
Location: Montreal
Contact:

Re: How to save a picture to file

Post by Devteam »

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
Post Reply