|
[Date Index]
[Thread Index]
[Author Index]
Re: How to give back to an image using "Net/Link" and "asp.net"?
- To: mathgroup at smc.vnet.net
- Subject: [mg46891] Re: How to give back to an image using "Net/Link" and "asp.net"?
- From: "Hans Michel" <hansjm at bellsouth.net>
- Date: Fri, 12 Mar 2004 23:40:14 -0500 (EST)
- References: <c2lph7$9c6$1@smc.vnet.net> <c2p9bo$dm3$1@smc.vnet.net> <c2ro3g$p6i$1@smc.vnet.net>
- Reply-to: "Hans Michel" <hansjm at bellsouth.net>
- Sender: owner-wri-mathgroup at wolfram.com
Roger:
Sorry for the spam earlier.
look this worked for me.
WebForm1.aspx HTML
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="mathGraph.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<IMG style="Z-INDEX: 101; LEFT: 24px; POSITION: absolute; TOP: 16px"
height="200" alt=""
src="WebForm2.aspx" width="200" runat="server">
</form>
</body>
</HTML>
WebForm1.aspx vbCodeBehind
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
End Class
WebForm2.aspx HTML
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm2.aspx.vb"
Inherits="mathGraph.WebForm2" EnableSessionState="False"
enableViewState="False" contentType="image/jpeg"%>
WebForm2.aspx vbCodeBehind
Imports Wolfram.NETLink
Imports System.Drawing
Imports System.Drawing.Imaging
Public Class WebForm2
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
Dim MathKernel1 As Wolfram.NETLink.MathKernel
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
MathKernel1 = New Wolfram.NETLink.MathKernel
'
'MathKernel1
'
MathKernel1.AutoCloseLink = True
MathKernel1.CaptureGraphics = False
MathKernel1.CaptureMessages = False
MathKernel1.CapturePrint = False
MathKernel1.GraphicsFormat = "Automatic"
MathKernel1.GraphicsHeight = 200
MathKernel1.GraphicsResolution = 96
MathKernel1.GraphicsWidth = 200
MathKernel1.HandleEvents = True
MathKernel1.Input = Nothing
MathKernel1.Link = Nothing
MathKernel1.LinkArguments = Nothing
MathKernel1.PageWidth = 0
MathKernel1.ResultFormat =
Wolfram.NETLink.MathKernel.ResultFormatType.OutputForm
MathKernel1.UseFrontEnd = True
'------------------------------------------
Dim mlArgs As String
mlArgs = "-linkmode launch -linkname ""C:/Program Files/Wolfram
Research/Mathematica/5.0/mathkernel.exe"""
Dim ml As IKernelLink = MathLinkFactory.CreateKernelLink(mlArgs)
'------------------------------------------
'Method 1
'Start of Method 1
MathKernel1.Link = ml
If (MathKernel1.IsComputing()) Then
MathKernel1.Abort()
Else
MathKernel1.GraphicsHeight = 200
MathKernel1.GraphicsWidth = 200
MathKernel1.CaptureGraphics = True
MathKernel1.Compute("Plot3D[Sin[x y], {x, -Pi, Pi}, {y, 0,
10}]")
If (MathKernel1.Graphics.Length > 0) Then
Dim objBitmap As Bitmap = New
Bitmap(MathKernel1.Graphics(0))
objBitmap.Save(Response.OutputStream, ImageFormat.Jpeg)
End If
End If
'End of Method 1
'------------------------------------------
'Method 2
'Start of Method 2
'ml.WaitAndDiscardAnswer()
'ml.EvaluateToImage("Plot3D[Sin[x y], {x, -Pi, Pi}, {y, 0, 10}]",
300, 200).Save(Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Jpeg)
'End of Method 2
'------------------------------------------
ml.Close()
ml = Nothing
End Sub
End Class
Also add this to your web config
as a child of
<system.web>
add
<identity impersonate="true"/>
The code behind in WebForm2 does not work please comment out method 1 and
uncomment method 2.
Hans
Prev by Date:
Re: Excessive Mathematica memory use, revisited.
Next by Date:
Re: mathematica and image... help me please
Previous by thread:
Re: How to give back to an image using "Net/Link" and "asp.net"?
Next by thread:
While or not to While that is the question :)
|