What I thought is that I would produce another plot (one
smaller one to show on the screen and another for printing)
with a huge bitmap to allow 300 dpi for about 15 cm by
8 cm (about 1800 pixels by 1000 pixels) which can be
saved as a bitmap and still be printed with fairly good
clarity. If 600 dpi is required, that too would be
feasible with 4 times as many pixels [3600 x 2000].
A standard full colour (24 bits per pixel) bitmap file of a size 3600 x 2000
pixels would indeed be feasible, but it would be extremely large (about 20
MB) for what is effectively a copy of a small 15 x 8 cm drawing. Also you
would need to carefully consider the different line widths etc that would be
required for creating the bitmap so that they are suitable for drawing onto
a high resolution device. Converting such a bitmap to a jpeg would reduce
the file size somewhat, but at the expense of quality. On the other hand a
metafile (.emf) would be very small by comparison (up to a thousand times
smaller or even more, depending on the complexity of the drawing), and would
contain exactly the same drawing but in a way that allows it to be printed
at any size you desire to any output device whilst maintaining the full
output quality of the device to which you are drawing it.
Metafiles would be nice, but there do not seem to be
any easy ways of writing them from VB. Any information
on this would be welcome.
As I mentioned in my previous posts I am a VB6 programmer myself and I am
really just "nosing about" in here, so I have never written any code to
create metafiles in VB.Net. I have written such code in VB6 though, but
because VB6 does not have any native metafile functions it is necessary to
create one using the CreateEnhMetafile API function and draw into the handle
it returns using pens and brushes that need to be created using the various
CreatePen, CreateBrush and CreateFont etc API functions (due to the fact
that standard VB6 drawing methods cannot be used on a metafile handle
because VB6 knows nothing about them). In VB6 this is a little bit complex
but it is actually much simpler than it sounds once you have got the main
basic routine off the ground. However I'm pretty sure that VB.Net has native
functions to create and draw into metafiles and so VB.Net should do most of
that work for you. In fact I've just "Googled" for information on the
subject and this is the first hit I got. It looks like it could be exactly
what you need:
Mike
It seems to be as simple as this:
' Make a metafile that can work with the hDC.
Dim mf As New Metafile(txtFile.Text, hdc, _
New Rectangle(0, 0, 210, 210), _
MetafileFrameUnit.Pixel)
' Make a Graphics object to work with the metafile.
Dim mf_gr As Graphics = Graphics.FromImage(mf)
' Draw on the metafile.
Dim the_pen As New Pen(Color.Blue, 5)
mf_gr.DrawRectangle(the_pen, 5, 5, 190, 190)
The key is to create Graphics.FromImage(metafilename)
and then draw on it. Finally, it is saved as gr.DrawImage(mf, 0, 0)
See, VB.net does have some added value. They might be fooling us with
the name, but this new thing is worthwhile learning.- Piilota siteerattu teksti -
- Näytä siteerattu teksti -