Under Windows 2000 and XP I can succesfully export a Tchart to an image using:
Public Shared Function GetImage(ByVal chart As TChart) As Image
Dim strm As New IO.MemoryStream
With chart.Export.Image.Metafile
.Enhanced = True
.Width = chart.Width
.Height = chart.Height
.Save(strm)
strm.Position = 0
End With
Dim img As Image = Image.FromStream(strm)
strm.Flush()
strm.Close()
Return img
End Function
But running this code under Windows 98 Second edition the SAME program terminates with the following error:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.InvalidOperationException: The object is currently in use elsewhere.
at System.Drawing.Graphics.Dispose(Boolean disposing)
at System.Drawing.Graphics.Dispose()
at Steema.TeeChart.Export.MetafileFormat.SaveMetafile(Object FileOrStream)
at Steema.TeeChart.Export.MetafileFormat.Save(Stream stream)
at TchartTest.Form1.GetImage(TChart chart)
at TchartTest.Form1.Button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
TchartTest
Assembly Version: 1.0.1964.26268
Win32 Version: 1.0.1964.26268
CodeBase: file:///C:/TCHARTTEST.EXE
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
TeeChart
Assembly Version: 1.1.1879.21176
Win32 Version: 1.1.1879.21176
CodeBase: file:///C:/TeeChart.DLL
----------------------------------------
************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
Please tell us if this gets fixed!
MetaFile Export and Windows 98
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi CitoTChartUser,
Can you create a metafile in Win 98 using .NET Framework native methods?
In case you were using dotted lines, it is only supported by windos NT, 2000, 2003 and XP.
Can you create a metafile in Win 98 using .NET Framework native methods?
In case you were using dotted lines, it is only supported by windos NT, 2000, 2003 and XP.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 8
- Joined: Mon Mar 01, 2004 5:00 am
Yes we can create a metafile UNDER windows 98 using the .NET native methods.
We only use area's and 'standard lines' (not dotted, because they look too fat/ugly anyway).
This is a real problem for us, we are able to export to PNG under w98 (but the image looks too ugly, so we would like see this fixed)
Now something else: We can only export to metafile or PNG:
Why can't we [stream] export to JPEG, GIF or Bitmap (tested under Windows 2000 Prof. SP4), we always get the following error when we try to save or use the image
Run-time exception thrown : System.Runtime.InteropServices.ExternalException - Er is een generieke fout opgetreden in GDI+. [translated: A generic error occured in GDI+]
Regards, Jan
We only use area's and 'standard lines' (not dotted, because they look too fat/ugly anyway).
This is a real problem for us, we are able to export to PNG under w98 (but the image looks too ugly, so we would like see this fixed)
Now something else: We can only export to metafile or PNG:
Why can't we [stream] export to JPEG, GIF or Bitmap (tested under Windows 2000 Prof. SP4), we always get the following error when we try to save or use the image
Code: Select all
Private Shared Function getImageJPEG(ByVal chart As TChart) As Image
Dim strm As New IO.MemoryStream
With chart.Export.Image.JPEG 'Or .Bitmap or .GIF
.Width = chart.Width
.Height = chart.Height
.Save(strm)
strm.Position = 0
End With
Dim img As Image = Image.FromStream(strm, True, True)
strm.Flush()
strm.Close()
Return img
End Function
Regards, Jan
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Jan,
This problem can be solved commenting the MemoryStream.Close() line. This error is described at this Microsoft support article.
This code works fine:
This problem can be solved commenting the MemoryStream.Close() line. This error is described at this Microsoft support article.
This code works fine:
Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Img As Image
Img = getImageJPEG(TChart1)
Img.Save("C:\test.jpg", Imaging.ImageFormat.Jpeg)
End Sub
Private Shared Function getImageJPEG(ByVal chart As Steema.TeeChart.TChart) As Image
Dim strm As New IO.MemoryStream
With chart.Export.Image.JPEG 'Or .Bitmap or .GIF
.Width = chart.Width
.Height = chart.Height
.Save(strm)
strm.Position = 0
End With
Dim img As Image = Image.FromStream(strm, True, True)
'strm.Close() 'problematic line
Return img
End Function
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 8
- Joined: Mon Mar 01, 2004 5:00 am
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Jan,
It's hard to tell as it can have several causes and a combination of things leading to them. However I've given you an alternative using .NET native methods to your newest thread regarding Win 98 Metafile export.
It's hard to tell as it can have several causes and a combination of things leading to them. However I've given you an alternative using .NET native methods to your newest thread regarding Win 98 Metafile export.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |