Re: large bitmaps for printing (GDI+)

From: semhelp (semhelp_at_discussions.microsoft.com)
Date: 01/11/05


Date: Tue, 11 Jan 2005 14:17:05 -0800

Thanks for the response--but I have a couple of questions:

I'm not 'loading' an image from disk. I allocate a 16bpp bitmap and then
draw to it. Are you saying that at some point, it is stored at 32bpp
internally?

To generalize my original question a little--How do you print a CAD drawing
to postscript plotters (large page size) at good resolution without using
many gigs of memory?

I'm trying to print a bitmap image because there appears to be problem when
sending metafile data with transparency to postscript printers. I have
shapes drawn with different hatch brushes on different layers. If I use the
standard printing approach (drawing to e.graphics in the printdocument
routine) the transparency doesn't work. Microsoft has documented this issue
and recommends printing as an bitmap image.

So I'm drawing to a bitmap and then using e.graphics.drawimageunscaled in
the printdocument routine to print. As you point out, this uses a lot of
memory as the bitmaps get larger.

Will it help if I draw 1/4th of the image to a quarter size bitmap and then
call e.graphics.drawimageunscaled to draw the image in the upper left corner
and then draw another 1/4th of the image to the bitmap and call
e.graphics.drawimageunscaled to draw the image in the upper right corner,
etc. This way, I'm not allocating as large of a bitmap, but I'm not sure
about how the printing object allocates memory.

I don't have the luxury of a many gigibyte machine either--I just want a
good resolution plot. Any ideas?

"Bob Powell [MVP]" wrote:

> An image of this size is 1.6 gigabytes in size. There is no way to use such
> an image in a compressed form. When images are loaded they are expanded to
> their full 32 bpp size when they are first used.
>
> You'd need a machine with at least 3 gigs of hard memory on board to even
> think about printing this. 5 might be better.
>
> AFAIK there are no numerical limits other than the size of the integer
> values for the dimensions of a bitmap. the problems soon arise however when
> bitmap size approaches available memory size.
>
> I've never had the luxury of an n gigabyte computer system to test such
> things.
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Find great Windows Forms articles in Windows Forms Tips and Tricks
> http://www.bobpowell.net/tipstricks.htm
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/faqmain.htm
>
> All new articles provide code in C# and VB.NET.
> Subscribe to the RSS feeds provided and never miss a new article.
>
>
>
>
>
> "semhelp" <semhelp@discussions.microsoft.com> wrote in message
> news:8323693A-1FE9-41E2-A67E-7DE5E8D0F56E@microsoft.com...
> >I need to draw a bitmap from CAD data and then print it in color (at least
> >16
> > bits) at 600DPI to a large page. The resulting bitmap can be as large as
> > 20000 x 20000 pixels. What is the best way to work with these large
> > images?
> > Is there some way to work with them in a compressed format? If you have
> > an
> > image in .png format, can you draw to it with standard graphics methods
> > while
> > the image is still compressed?
> >
>
>
>



Relevant Pages

  • Re: Memory problems, I think...
    ... > take a DC as an argument, but is this where it is going to take up less memory? ... creating a bitmap in memory that is 15000x10000 pixels takes up more memory ... Remember that when you draw to a normal DC, you're not actually drawing to the DC itself but to the Bitmap ...
    (microsoft.public.vb.winapi.graphics)
  • Re: One thing I noticed
    ... >I did a test drawing 10,000 lines using vb code, it didn't draw to the ... >Out of the 3 methods (drawing direct to screen, drawing to bitmap or using ... >autoredraw) it is always the least efficient. ... - if one did an audit on Windows memory usage ... ...
    (microsoft.public.vb.general.discussion)
  • Re: GC problem with large object - .net 1.1
    ... allocate new bitmap with any size-step, ... BUT the GC does not give the memory back to the system. ... Usage" (Working Set, the amount of memory that Windows has allocated to ...
    (microsoft.public.dotnet.framework)
  • Re: [RFC][PATCH -mm 1/5] swsusp: Introduce memory bitmaps
    ... structure that will require less memory, such as a pair of bitmaps. ... reason the memory bitmap structure consists of several linked lists of objects ... that contain pointers to memory pages with the actual bitmap data. ... the bitmaps are created and we allocate as many image pages as needed ...
    (Linux-Kernel)
  • Re: One thing I noticed
    ... I did a test drawing 10,000 lines using vb code, it didn't draw to the ... Although if you're talking about the API drawing then I ... Out of the 3 methods (drawing direct to screen, drawing to bitmap or using ... > That would be true if we did not have Virtual Memory ...
    (microsoft.public.vb.general.discussion)