2

I have an Expr object in C#, which represents Wolfram Mathematica's type - it can hold a number, a mathematical expression, a sound, an image or others.

I had been using the tutorial included with my Wolfram Mathemtica edition for calling Mathematica via .NET, and I want to create an Image from my output. For example, to plot a function or nicely draw an expression.

I have this code:

public System.Drawing.Image ToImage(int width = 300, int height = 300)
{
    return link.EvaluateToImage(this.e, width, height);
}

Where link is my IKernelLink, and this.e is my Expr.

Afterwards, I use image.Save(@"C:\file.png")

The problem is that when I open a form and do form.pictureBox.Image = LoadImage(@"C:\file.png"), or I open the the image with the appropriate program, it gives me an animation of three frames. I will upload it here:

enter image description here

Additionally, it does not give me the whole output, which is {{x -> -(-3)^(1/3)}, {x -> 3^(1/3)}, {x -> (-1)^(2/3)*3^(1/3)}} (generated with EvaluateToInputForm)
Obviously, this behavior is wrong and can anybody help me with it?


note: it makes a single frame file when the Expr is a graphic object, i.e the evaluation of a Plot function.

4

1 に答える 1

2

I think you should use a Graphics array to send a collection of images from Mathematica to .NET, ie:

.NET/Link MathKernel.Graphics Property

There is an example of the use of this code here.

于 2012-05-23T07:25:43.237 に答える