Printing of high-resolution bitmaps

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Roman (anonymous_at_discussions.microsoft.com)
Date: 05/17/04

  • Next message: Norvin Laudon: "Re: Rounded Corners on Translucent Form"
    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.


  • Next message: Norvin Laudon: "Re: Rounded Corners on Translucent Form"

    Relevant Pages

    • Re: Print Preview (again?)
      ... > the discrepancy of bitmap sizes between the screen and print-outs. ... > You have a screen with some resolution, ... > As for the second copy of the text, in a much larger font, we will have to ... > called the hardware margin - and it must also be taken into consideration. ...
      (microsoft.public.vc.mfc)
    • Re: Print Preview (again?)
      ... > the discrepancy of bitmap sizes between the screen and print-outs. ... > You have a screen with some resolution, ... > As for the second copy of the text, in a much larger font, we will have to ... > called the hardware margin - and it must also be taken into consideration. ...
      (microsoft.public.vc.mfc)
    • Re: Print Preview (again?)
      ... >> resolution is for all of the screen, and the printer resolution is per ... Thus the very small bitmap. ... >> As for the second copy of the text, in a much larger font, we will have ... >> StretchBlt is then used to render the bitmap to the output device. ...
      (microsoft.public.vc.mfc)
    • Re: Office 2001 --> office 2004
      ... "placeable header", usually a low-resolution bitmap. ... resolution, ...  the issues in graphics between 2001 and 2004 were never ... McGhie Information Engineering Pty Ltdhttp://jgmcghie.fastmail.com.au/ ...
      (microsoft.public.mac.office.word)
    • Re: Print Preview (again?)
      ... the discrepancy of bitmap sizes between the screen and print-outs. ... You have a screen with some resolution, ... As for the second copy of the text, in a much larger font, we will have to ... called the hardware margin - and it must also be taken into consideration. ...
      (microsoft.public.vc.mfc)