Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Converting Metafile into TIFF file

21 views
Skip to first unread message

Rahul Aggarwal

unread,
Feb 28, 2005, 10:11:15 AM2/28/05
to
I am trying to convert a ACE file with a 96 dpi resolution to a meta file
and then convert the metafile into a TIFF file (black and white 200 dpi, 1
bit depth). I create the metafile and metafile canvas with the following
code:

mmfMetaFile := TMetaFile.Create;
mmfMetaFile.Enhanced := True;

// I calculate the height and width of the canvas based on the width and
height of the original
// ACE document with had been originally sent to the screen (with a 96 dpi)


//I have tried changing the the height and width by multiplying by 200
instead of 96 and increasing
//the vertical and horizontal scale of the Ace component from 100 to 200 but
even if the size of the
//WMF is larger the resolution is still 96 dpi.
miPageHeight := Round(aceInputAceFile.AcePrinterSetup.Width*
Screen.PixelsPerInch);
miPageWidth := Round(aceInputAceFile.AcePrinterSetup.Length*
Screen.PixelsPerInch);

//
mmfMetaFile.Height := miPageHeight;
mmfMetaFile.Width := miPageWidth;

//create the canvas and associate it with the meta file
mmfCanvas := TMetaFileCanvas.Create(mmfMetaFile, 0) ;

//I tried setting this property but it did not work
//mmfCanvas.Font.PixelsPerInch := 200;

aceInputAceFile.PlayPage(mmfCanvas.Handle, miIndex);
mmfCanvas.Free;
mmfMetaFile.SaveToFile(msTmpMetaFileName);
...

This is where I have my concern. If I pass a 0 for the reference device then
the metafile canvas is created based on the Screen resolution which is 96
dpi also. How can change this so the metafile canvas is created with a
resolution of 200 dpi. I tried passing the Printer.Handle of an attached
Printer but it was 600 dpi and I would have to change the width and height
of the metafile to a much larger size.
Even if the metafile is created with a 96 dpi can I load it in a TBitmap to
change its resolution in any manner possible. I have been using the Envision
Image components to finally convert the the WMF file into a TIFF file.

I would appreciate any help on this or if you have a different set of
components to use for the final TIFF file.


Thanks.


Joris Van Damme

unread,
Feb 28, 2005, 12:31:06 PM2/28/05
to
> ...or if you have a different set of

> components to use for the final TIFF file.

By far the most widely used TIFF library is LibTiff. A pre-compiled version
of LibTiff is available for free download here:

http://www.awaresystems.be/imaging/tiff/delphi.html

It links into your Delphi project just like the LibJpeg units that Borland
distributes with Delphi, i.e. it is compiled with C++ Builder into .obj
units. Thus, there is no DLL involved, no external dependency, no
distribution nightmare.

Many people reported that they felt it was way more comfortable then the
Envision library, but I couldn't comment on that from personal experience as
I've never used the Envision library.

Joris Van Damme
in...@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html


Yannis

unread,
Feb 28, 2005, 12:50:39 PM2/28/05
to
> ....

>
> This is where I have my concern. If I pass a 0 for the reference device then
> the metafile canvas is created based on the Screen resolution which is 96
> dpi also. How can change this so the metafile canvas is created with a
> resolution of 200 dpi. I tried passing the Printer.Handle of an attached
> Printer but it was 600 dpi and I would have to change the width and height
> of the metafile to a much larger size.
> Even if the metafile is created with a 96 dpi can I load it in a TBitmap to
> change its resolution in any manner possible. I have been using the Envision
> Image components to finally convert the the WMF file into a TIFF file.
>
>
>
> I would appreciate any help on this or if you have a different set of
> components to use for the final TIFF file.
>
>
> Thanks.
>
>
> From - Mon

You know that DPI has no meaning on a bitmaped file format
other than to calculate the image dimensions in to a human
system right?

What I mean is that DPI is used only to calculate the size of
a bitmap in cm, mm, inches etc (i do not know the effect of
vector formats like wmf, emf, cdr etc).

When you see a 200 dpi image it meens that 200 pixels equals to
one inche if the image you want to save is to be printed
in one square inche space then it has to have 200 pixels per
line and 200 lines.

Now the question is how big do you want the image to be.
If the the image is 10x11 inches long on 200 dpi creating
a bitmap of 2000x2200 pixels and drawing the meta file to it
is what you need to do in order to accomplish your task.
The DPI value on the bitmap header can change with out changing
the actual image size but it will affect the printed size only.


Regards
Yannis.

0 new messages