Printing of high-resolution bitmaps
From: Roman (anonymous_at_discussions.microsoft.com)
Date: 05/17/04
- Previous message: karol: "Font creation and GetCharABCWidthsFloat() problem"
- Next in thread: Roman: "RE: Printing of high-resolution bitmaps"
- Reply: Roman: "RE: Printing of high-resolution bitmaps"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 17 May 2004 12:36:13 -0700
Hello,
Recently I tried to print bitmap with resolution of printer and discovered the next problems:
1. I have a bitmap (300 dpi, Format8bppIndexed) 230 x 2850 pixels (about 650,000 pixels in total).
When I print it (using Graphics.DrawImage) and check spooling info for printer I see >30 Mb is being spooled.
In other words 50 times more then original size of bitmap. I can imagine that indexed 8-bit bitmap is converted
to 32-bit ARGB bitmap first. This would increase the size of bitmap from 650 Kb to 2.5 Mb.
But still 30 Mb / 2.5 Mb = 12 times. Why?
2. Let's say I print on Letter format paper 8 x 11.5 inches. Let's say I have 1 inch margins on each side.
This leaves 6 x 9.5 inches of printable area. When I try to print bitmap (300 dpi) with dimensions equal
to printable area of page (width = 6 x 300 = 1800 pixels, height = 9.5 x 300 = 2850 pixels,
about 5 Megapixel in total - comparable to the picture size of average digital camera) I get the next exception
in Graphics.DrawImage method:
"An unhandled exception of type System.Runtime.InteropServices.ExternalException
occured in system.drawing.dll"
"Additional information: A generic error occured in GDI+"
Honestly I'm not too much surprised: 5 Mb multiplied by 50 times overhead gives 250 Mb
of spooled data. I don't think that average printer can handle this... Though, I'm not sure
if the "OutOfMemory" is the reason for ExternalException I'm getting.
On the other hand when I do "print to file" or "print preview" for the same bitmap with
the same bitmap and device resolutions everything works fine.
3. Similar problem exists in Java by the way (Java from Sun Microsystems).
Though in the case of Java there is "a workaround" that helps if you print
on black and white printer. If you convert 8-bit indexed color bitmap to
java.awt.image.BufferedImage.TYPE_BYTE_GRAY then spooling size is
reduced 5 times. Probably because printer (or driver) "understands"
that bitmap is already grayscale and no conversion is necessary.
In GDI+ there is only one grayscale format for bitmap: Format16bppGrayScale.
And it does not work - thanks to Bob Powell who explained why.
I tried different printers (old, new, b/w, color) - all symptoms are the same.
I tried to break one "big" bitmap into many "small" bitmaps and call Graphics.DrawImage
for each of them. It does not help. Probably it does not help because printer tries to form
a page and again runs out of memory. In debugger I could see that several small bitmaps
were processed before exception was thrown.
So, the questions are:
1. How to print out 2,000 x 3,000 bitmap?
2. How to reduce the size of spooling data?
Any ideas and advices are appreciated.
Thanks.
- Previous message: karol: "Font creation and GetCharABCWidthsFloat() problem"
- Next in thread: Roman: "RE: Printing of high-resolution bitmaps"
- Reply: Roman: "RE: Printing of high-resolution bitmaps"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|