MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Mathematica Graphics output in an ASP.NET WebApplication II

  • To: mathgroup at
  • Subject: [mg54685] Mathematica Graphics output in an ASP.NET WebApplication II
  • From: "Javier Chicote" <goraperas at>
  • Date: Sun, 27 Feb 2005 01:29:09 -0500 (EST)
  • Sender: owner-wri-mathgroup at


I would like to place the Mathematica Graphics output in an ASP.NET
WebApplication using Wolfram.NETLink referente, like in the example of

First of all, I tried to use the mathKernel.Graphics property to get the
image from the Mathematica graphics output during the last call to
mathKernel.Compute(). The problem is that in WebForms I cannot use
System.Windows.Forms.PictureBox that I can use in Windows, so I need to
refer a URL for the System.Web.UI.WebControls.Image when I only have a
System.Drawing.Image object.

Then, I check out the possibilies proposed in Wolfram MathGroup:

       How to give back to an image using "Net/Link" and ""?

       how to save a mathematica-made imagebox.image as jpg, gif, bmp in

       Mathematica Graphics output in an ASP.NET WebApplication

Now I have 2 WebForms, but I still haven't found the solution to my problem,
althought I can see the graphic in certain cases.


In WebForm1.aspx I define the image:


<IMG id="Img1" style="Z-INDEX: 116; LEFT: 496px; POSITION: absolute; TOP:
16px" height="200" src="Graphics.aspx" width="200" runat="server"></form>

Graphics.aspx is the WebForm that I use as an image:


<%@ Page language="c#" Codebehind="Graphics.aspx.cs" AutoEventWireup="false"
Inherits="MathKernelAppWeb.Graphics" EnableSessionState="False"
enableViewState="False" contentType="image/jpeg"%>


protected string input;

protected System.Drawing.Image image;

private void Page_Load(object sender, System.EventArgs e)


       input = "Plot3D[Sin[x y], {x, -Pi, Pi}, {y, 0 ,10}]";           //1

       image = WebForm1.mathKernel.Link.EvaluateToImage(input,200,200);//2

       image.Save(Response.OutputStream, ImageFormat.Jpeg);



The previos code works, but I have two problems:

1) It is supposed that the application runs in WebForm1, so I need to pass
the input string from WebForm1 to Grapthics, and I don't know how to do

2) I would like to use the mathKernel.Compute() method and the the
mathKernel.Graphics[0] property instead of
mathKernel.Link.EvaluateToImage(), it's supossed that they do the same task
but it doesn't work if I do this:


       image = WebForm1.mathKernel.Graphics[0];

or this:

       Bitmap bmp = new Bitmap(WebForm1.mathKernel.Graphics[0]);

       image = (System.Drawing.Image) bmp;

In the explanation that Todd Gayley gives in of the articles above says that
maybe it could be a bug in Mathematica. If so, I would really appreciate if
you could inform me if it's solved in Mathematica 5.1 or newer versions.


       Javier Chicote

  • Prev by Date: Re: Why are permutations dupl
  • Next by Date: Re: legend scaling
  • Previous by thread: Re: Why are permutations dupl
  • Next by thread: Any simple fuzzy logic tool ?