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:
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.