Problem Emf images with memory streal

When trying to put a barcode as Emf in a memory stream I get an System.ArgumentNullException error:
Value cannot be null.
Parameter name: encoder

Stack trace:
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(Stream stream, ImageFormat format)
at WindowsFormsApplication1.Form1.Form1_Load(Object sender, EventArgs e) in C:\TEMP\WindowsFormsApplication1\Form1.cs:line 45
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WindowsFormsApplication1.Program.Main() in C:\TEMP\WindowsFormsApplication1\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()


The following code simulates the problem
//Create barcode builder
Aspose.BarCode.BarCodeBuilder bb;
bb = new Aspose.BarCode.BarCodeBuilder();
bb.CodeText = “10000274”;
bb.BorderVisible = false;
bb.BarHeight = 15f;
bb.SymbologyType = Aspose.BarCode.Symbology.EAN8;
bb.xDimension = 0.6f;
bb.Resolution.DpiX = 300f;
bb.Resolution.DpiY = 300f;
bb.CodeLocation = CodeLocation.None;

System.IO.MemoryStream ms;
ms = new System.IO.MemoryStream();
bb.BarCodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Emf); //this line produces the error

When using jpeg there is no problem :
bb.BarCodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

When saving the barcode as Emf to a file (not a memory stream) it works also:
bb.Save(“barcode.emf”, System.Drawing.Imaging.ImageFormat.Emf);



Hi,

I can also reproduce the issue at my end using the sample code above. I have logged this as a bug in our issue tracking system (ID: 15355). We will notify you when it will be fixed. Sorry for the inconvenience.

Want to sort out your problem,go through cheap-upc-barcode.com,see it can help you.Thanks.

Hi,


The reason why this exception occurs while saving in EMF or WMF format is because it is not supported by the .NET framework. Please refer to http://support.microsoft.com/kb/316563 article for further details.

The issues you have found earlier (filed as 15355) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.