[Date Index]
[Thread Index]
[Author Index]
Mathematica Graphics output in an ASP.NET WebApplication II
*To*: mathgroup at smc.vnet.net
*Subject*: [mg54685] Mathematica Graphics output in an ASP.NET WebApplication II
*From*: "Javier Chicote" <goraperas at hotmail.com>
*Date*: Sun, 27 Feb 2005 01:29:09 -0500 (EST)
*Sender*: owner-wri-mathgroup at wolfram.com
Hi,
I would like to place the Mathematica Graphics output in an ASP.NET
WebApplication using Wolfram.NETLink referente, like in the example of
C:\...\Mathematica\5.0\AddOns\NETLink\Examples\Part2\MathKernelApp.
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 "asp.net"?
http://forums.wolfram.com/mathgroup/archive/2004/Mar/msg00143.html
how to save a mathematica-made imagebox.image as jpg, gif, bmp in
c#/.netlink?
http://forums.wolfram.com/mathgroup/archive/2004/May/msg00087.html
Mathematica Graphics output in an ASP.NET WebApplication
http://forums.wolfram.com/mathgroup/archive/2005/Jan/msg00238.html
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:
HTML:
<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:
HTML:
<%@ Page language="c#" Codebehind="Graphics.aspx.cs" AutoEventWireup="false"
Inherits="MathKernelAppWeb.Graphics" EnableSessionState="False"
enableViewState="False" contentType="image/jpeg"%>
Code:
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
this.
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:
WebForm1.mathKernel.Compute(input);
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.
Thanks,
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 ?**
| |