Re: graphics & printing



On Sun, 15 Apr 2007 16:09:55 -0700, jake <jakedimano@xxxxxxxxx> wrote:

When I draw (using DrawString() and other Draw...() methods) directly
to the PrintDocument using the PrintDocument's PrintPageEventArgs e,
the print-out comes out nice and sharp. But when I direct my graphics
to memory first then using PrintDocument's PrintPageEventArgs
e.DrawImage(), I get the image printed with the right scale and
everything, but the characters and everything else is blurry, out of
focus and just generally very bad.

I don't think "fuzzy" is a precise enough description of what's going wrong for anyone to say for sure what you need to fix.

However, I'll suggest a couple of things. First, modern printers have resolutions *much* higher than 1/100th of an inch (that would be 100 dpi), while screen resolution is generally fixed at much less than 1/300th of an inch (that would be 300 dpi, whereas the default under Windows is 96 dpi, though it's hard to make a perfect determination due to varying display sizes and resolutions). Second, if you draw your image to memory first then the resolution of the image is limited to the resolution of the destination memory image (Bitmap in this case, I assume). If you simply use the default resolution for a memory image, then the image is going to be lower resolution when drawn to memory first.

If you feel that you need to draw your image to memory before printing, there are a couple of ways you can avoid the loss of resolution. The first would be to create a Bitmap that has the same resolution as the destination printer. Of course, you need to get the printer resolution to do this, and of course the memory required may be large, or even prohibitive (depending on the resolution of the printer and the size of the paper).

An alternative would be to draw to a Metafile first, instead of a Bitmap. The basic mechanism is essentially the same, but rather than your drawing being rasterized into a pixel-based bitmap, the actual drawing calls are recorded into the metafile. This has two effects: one, the size can be much smaller, because its the commands that are stored, not each individual pixel; and two, since the original drawing calls are stored, when they are played back (drawn) to the printer, the full resolution of the printer is used.

The above may or may not be of use. Since your problem description is so vague it's hard to know what exactly the problem is. But hopefully it's relevant.

Pete
.



Relevant Pages

  • Re: Creating a DC with a given pixel-per-inch resolution
    ... You don't need a DC with specific resolution as you describe. ... You simply need a bitmap of ... code gets the printer parameters, sets its scaling properly, and draws to the DC it has. ... take the massive amount of memory a printer-sized bitmap will require. ...
    (microsoft.public.win32.programmer.gdi)
  • Creating a DC with a given pixel-per-inch resolution
    ... is there a way of creating a memory DC which can have an arbitrary value for LOGPIXELSX and LOGPIXELSY? ... The component calls GetDeviceCaps to retrieve the resolution in order to position the elements it draws on the page. ... Now I want to redirect the output to a memory DC. ... I want this bitmap to have a specific resolution so I think I need a DC with that resolution. ...
    (microsoft.public.win32.programmer.gdi)
  • Re: PrintDocument to a in memory Grapics object, How to?
    ... You could create a Bitmap in memory, with the same size and resolution as ... and obtain a Graphics handle to that Bitmap. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: change screen resolution in wince
    ... there is a bios setup feature for the amount of memory used as video memory. ... the resolution with the options that go with the loadcepc command line. ...
    (microsoft.public.windowsce.embedded)
  • Re: change screen resolution in wince
    ... there is a bios setup feature for the amount of memory used as video memory. ... If you use the flat vga driver. ... the resolution with the options that go with the loadcepc command line. ...
    (microsoft.public.windowsce.embedded)