Re: Embed in word



You actually don't need to embed anything into word to accomplish the task
you have described. Just draw your graphics as vectors instead of bitmap and
no blurring will ocurr.

It's possible with GDI, but you'll need to apply a little hack:

using (Graphics g = this.CreateGraphics()) //or Graphics from your paint
event
{
IntPtr dc = g.GetHdc();

using (Metafile metafile = new Metafile("foo.wmf", dc)) //your vector image
will be stored as foo.wmf
{
using (Graphics graphics = Graphics.FromImage(metafile))
{
graphics.DrawEllipse(Pens.Red, new Rectangle(0, 0, 50, 50));
//do your drawing here

//metafile.Save("boo.wmf", ImageFormat.Wmf); //I first guessed this
should allow you to save the image but this would throw a "generic error"
from GDI, so "foo.wmf" will be the only place where the image gets saved
}
}
}

Just insert the result (foo.wmf) into word as any other image - but you can
scale this one without any blur.

This is the only way I've found that seems to work. Plain image.Save(name,
ImageFormats.Wmf) saves it as png, since there is no wmf encoder in GDI+.
This seems a little too hacky for me, but it works. If there's anyone who
knows how to save images as wmf in .NET in a "more straightforward way" I'd
be very glad to hear from him.

"MRe" <m.r.e.@.d.u.b.l.i.n...i.e> wrote in message
news:utBVbgURHHA.1212@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

Is there any way to write a graphical program in CSharp that could be
embedded into Word2000. I've read .NET doesn't support creation of ActiveX
controls (unless done using C++) but is there any other option, like an
existing ActiveX that can embed some CSharp program.

What I'd like to do is; whenever I'm writing an assignment for college, I
usually want to add some diagram that isn't easy to create with the tools
available to me, so I write a program to do it, take a snapshot, and put
it into the doc as a bitmap. However, when printing, the bitmap comes out
blurry, so if I could embed the program and send vector data to the
printer, that would be awesome!

Thanks for any help,
Kind regards,
Eliott



.



Relevant Pages

  • Re: The story: Painting bitmap to screen is slow
    ... The general "trick" behind great GDI+ performance is to do all drawing ... single bitmap to the screen. ... I heard Microsoft broke GDI acceleration for some operations in Vista. ... your configuration of Vista or graphics driver. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: The story: Painting bitmap to screen is slow
    ... GDI bitmap pointing to the same area of memory. ... onto a Graphics device context. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: GDI+ Image sizing
    ... I'm not familiar with memDC but the process of double buffering in GDI+ is ... In GDI+ you create an offscreen bitmap using a graphics object ... Use double buffering to avoid ugly flashing. ...
    (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: The story: Painting bitmap to screen is slow
    ... single bitmap to the screen. ... Perhaps the GDI bitblit operation, ... do with your configuration of Vista or graphics driver. ... refer to the same area of memory, so you can use either API to transfer to ...
    (microsoft.public.dotnet.framework.drawing)