TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
gdman992002
NA
1
0
Create metafile in C# with specified resolution (dpi)
Sep 8 2004 7:34 PM
Hello, I'm fairly new to C# .NET and have been working with GDI+ and creating metafiles. I am having one particluar problem however. I am trying to create a metafile that has a certain minimum resolution (specifically, one that has at least 300 dpi for both the x and y axes). I have figured out how to create the metafile using a memory stream, bounding rectangle, and Metafile units like so: PrinterSettings printerSettings = new PrinterSettings(); Graphics graphics = printerSettings.GetMeasurementGraphics(); IntPtr ipHdc = graphics.GetHdc(); Metafile mf = new Metafile( new System.IO.MemoryStream(), ipHdc, new Rectangle( 0, 0, 0, 0 ), MetafileFrameUnit.Document, EmfType.EmfPlusDual ); graphics.ReleaseHdc( ipHdc ); graphics.Dispose(); Graphics grfxMetafile = Graphics.FromImage( mf ); // .. from here, do drawing, etc.... Now I create the metafile just fine and can draw to it, yadda yadda. The problem comes with the Graphics object I use to create the metafile and the drawing. I need the output dpi to be very high (300) because when I send this to the poster printer, i need very high resolution or it looks bad. So I'm stuck trying to get a high dpi device to get a Graphics object with a high dpi. So enter getting the graphics from the PrinterSettings. The problem is, what happens if there is no printer installed (printer settings get graphics call relies on a default printer being installed with a high dpi printer). When I copy/paste this metafile into other documents, I want the metafile to keep the high dpi I created it with. So my question is this: how do you create a high-dpi graphics object to create a metafile in order to have that metafile have a high dpi? Getting a Graphics from a bitmap or other image gives you a dpi that is of screen resolution (96dpi). Does it matter what dpi you use on your graphics object when creating the metafile? I am a bit confused on how to proceed, and google searches turn up mostly empty, or little useful information. Petzold uses the PrinterSettings in his book but as I mentioned I can't rely on a high dpi printer being installed. Any ideas? Thanks much in advance... gjb1
Reply
Answers (
0
)
A good DirectDraw tutorial
DXF plugin for .NET