.Net Graphics Image Resolution Issue-Help Required Urgently

0 views
Skip to first unread message

ShadowFax

unread,
Jul 22, 2005, 11:42:47 AM7/22/05
to DotNetDe...@googlegroups.com
Hi All,

I am writing a C# application that generates gifs that are going to be
printed on letter sized plain paper(8.5"X11").I also want these gifs to
be created at high resolutions so that their subsequent printouts are
clearer.
Here is the code for the gif to be created at 300ppi

Bitmap imgStampSheet=new Bitmap ((int)(8.5*300 ),(int)(11 * 300));
imgStampSheet.SetResolution (300 ,300);
Graphics gfxContext=Graphics.FromImage (imgStampSheet);
gfxContext.Clear ( System.Drawing.Color.White );
gfxContext.PageUnit =GraphicsUnit.Inch ;
// Render on the gfContext.
imgStampSheet.Save(modFilePath,System.Drawing.Imaging.ImageFormat.Gif
);

But to my surprise I find that when printed on a printer(without any
fit to paper settings) only a fraction of the gif is printed on a
single page and the rest in multiple pages.(requirement was for single
page)

Now after much googling I found out that the image can fit in the paper
if only I set the resolution to 96 and also the image size to
8.5X96,11X96.
It is seen that a measure of a inch comes to 96 always.What is this
magic number?
if that is the case Can I not generate images at higher resolutions and
get them to fit in one page?Is there some transformations that need to
be made on the Graphics object?
I think the basic question here is how does the resolution of the image
(that we set using SetResolution)map to its printout on printer.

Any pointers/info on this will be greatly appreciated.
Thanks in Advance.

Jonathan Dickinson

unread,
Jul 28, 2005, 5:20:43 AM7/28/05
to DotNetDe...@googlegroups.com
Why GIF? Does it support a resolution anyway? Try a png.

On 22/07/05, ShadowFax <arjun.ch...@gmail.com> wrote:

Hi All,

I am writing a C# application that generates gifs that are going to be
printed on letter sized plain paper( 8.5"X11").I also want these gifs to

be created at high resolutions so that their subsequent printouts are
clearer.
Here is the code for the gif to be created at 300ppi

Bitmap imgStampSheet=new Bitmap ((int)( 8.5*300 ),(int)(11 * 300));

imgStampSheet.SetResolution (300 ,300);
Graphics gfxContext=Graphics.FromImage (imgStampSheet);
gfxContext.Clear ( System.Drawing.Color.White );
gfxContext.PageUnit =GraphicsUnit.Inch ;
// Render on the gfContext.
imgStampSheet.Save(modFilePath,System.Drawing.Imaging.ImageFormat.Gif
);

But to my surprise I find that when printed on a printer(without any
fit to paper settings) only a fraction of the gif is printed on a
single page and the rest in multiple pages.(requirement was for single
page)

Now after much googling I found out that the image can fit in the paper
if only I set the resolution to 96 and also the image size to
8.5X96,11X96.
It is seen that a measure of a inch comes to 96 always.What is this
magic number?
if that is the case Can I not generate images at higher resolutions and
get them to fit in one page?Is there some transformations that need to
be made on the Graphics object?
I think the basic question here is how does the resolution of the image
(that we set using SetResolution)map to its printout on printer.

Any pointers/info on this will be greatly appreciated.
Thanks in Advance.




--
Thanks

Jonathan Dickinson
----------------------------
Phone: +27 15 276 5007
Cell: +27 73 559 4721
Email: jonathanc...@gmail.com
Reply all
Reply to author
Forward
0 new messages