Re: how to save a mathematica-made imagebox.image as jpg, gif, bmp in c#/.netlink?
- To: mathgroup at smc.vnet.net
- Subject: [mg48053] Re: how to save a mathematica-made imagebox.image as jpg, gif, bmp in c#/.netlink?
- From: "Hans Michel" <hansjm at bellsouth.net>
- Date: Sun, 9 May 2004 03:02:27 -0400 (EDT)
- References: <email@example.com>
- Reply-to: "Hans Michel" <hansjm at bellsouth.net>
- Sender: owner-wri-mathgroup at wolfram.com
cdj: Try this: private Bitmap MyImage ; MyImage = new Bitmap(mathKernel.Graphics); graphicsBox.Image = (Image) MyImage ; Hans "cdj" <a_cjones at hotmail.com> wrote in message news:c7fhje$oa1$1 at smc.vnet.net... > Hi all, > > This has been buggin me for awhile... I'm sure I'm doing something > silly, but I can't figure out what.... > > It suffices to consider the following problem: > > (1) Use the mathematica-supplied c# example (let's you enter a Mathematica > statement, compute, and captures output.) > > How to save a graphicsBox.Image to a file, say as a jpg? > > There's standard code that is available on msdn, to wit: > > (2) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtsksavingfilesusingsavefiledialogcomponent.asp > > When I try to join these 2 bits of code together, I get a totally > uninformative GDI+ error of some sort. > > I'm under the impression that the problem is that the Mathematica graphic > isn't being assigned to the picturebox in the "normal" way, or some > such thing. The reason I have this impression is that while the > following code-bits are quite similar, I can save with one, but not > with the other: > > (a) graphicsBox.Image = mathKernel.Graphics; > > (b) graphicsBox.Image = Image.FromFile("pathtomyfile.jpg"); > > Can anybody explain to me why the msdn routine works fine with (b), > but not with (a)? > > I've been brief here with the description of my problem - I'm happy to > expand a bit on anything above, if it would be helpful.... > > thx much for any insights, > > cdj >