I would like to use Wolfram.NETLink.MathKernel.Graphics to retrieve an image generated from a Mathematica command. Which Mathematica command do I use to do this?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Wolfram.NETLink;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
/*
MathKernel kernel = new MathKernel();
kernel.Compute("ExportString[Graphics[Rectangle[]],{\"Base64\",\"EMF\"}]");
byte[] decodedBytes = Convert.FromBase64String(kernel.Result.ToString());
File.WriteAllBytes("C:\\temp\\output.emf", decodedBytes);
*/
MathKernel k = new MathKernel();
k.CaptureGraphics = true;
k.GraphicsFormat = "GIF";
k.Compute("Show[Graphics[Rectangle[]]]");
k.Graphics[0].Save("C:\\temp\\file.gif", System.Drawing.Imaging.ImageFormat.Gif);
}
}
}