Bug 6451 - Icon saving corruption (jpg handling errors are fixed)
Summary: Icon saving corruption (jpg handling errors are fixed)
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Drawing ()
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-08-07 13:27 UTC by Gary____
Modified: 2012-10-11 07:17 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Example program (806 bytes, text/x-csharp)
2012-08-07 13:27 UTC, Gary____
Details
jpg causes errors (762.53 KB, image/jpeg)
2012-08-07 13:28 UTC, Gary____
Details
ico corrupts (113.56 KB, image/vnd.microsoft.icon)
2012-08-07 13:29 UTC, Gary____
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Gary____ 2012-08-07 13:27:12 UTC
Created attachment 2317 [details]
Example program

Developing an application that reads in image files and writes them out again ive noticed some errors and corruption on mono that doesn't happen on .NET. 

For the jpg attached, my application loads it through the ResX handling class (ResXFileRef). When i access the RawImageFormat property, I get the error below....

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: A null reference or invalid value was found [GDI+ status: InvalidParameter]
  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x0009b] in /home/garyb/mono/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs:220 
  at System.Drawing.Image.get_RawFormat () [0x0000e] in /home/garyb/mono/mcs/class/System.Drawing/System.Drawing/Image.cs:731 
  at (wrapper remoting-invoke-with-check) System.Drawing.Image:get_RawFormat ()
  at MonoDevelop.NETResources.LinkableObjectProvider.GetExtension (System.Object obj) [0x0002a] in /home/garyb/MDProjects/NETResources/NETResources/LinkableObjectProvider.cs:93 
  at MonoDevelop.NETResources.LinkableObjectProvider.set_Persistence (Persistence value) [0x0001e] in /home/garyb/MDProjects/NETResources/NETResources/LinkableObjectProvider.cs:29 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000d5] in /home/garyb/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:229 
  --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000eb] in /home/garyb/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:237 
  at System.Reflection.MonoProperty.SetValue (System.Object obj, System.Object value, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] index, System.Globalization.CultureInfo culture) [0x0006a] in /home/garyb/mono/mcs/class/corlib/System.Reflection/MonoProperty.cs:363 
  at System.Reflection.PropertyInfo.SetValue (System.Object obj, System.Object value, System.Object[] index) [0x00000] in /home/garyb/mono/mcs/class/corlib/System.Reflection/PropertyInfo.cs:93 
  at System.ComponentModel.ReflectionPropertyDescriptor.SetValue (System.Object component, System.Object value) [0x00038] in /home/garyb/mono/mcs/class/System/System.ComponentModel/ReflectionPropertyDescriptor.cs:272 
  --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000eb] in /home/garyb/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:237 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /home/garyb/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:101 
  at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x000d7] in /home/garyb/mono/mcs/class/corlib/System/Delegate.cs:424 
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00018] in /home/garyb/mono/mcs/class/corlib/System/MulticastDelegate.cs:72 
  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in /home/garyb/mono/mcs/class/corlib/System/Delegate.cs:398 
  at GLib.Signal.ClosureInvokedCB (System.Object o, GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0 
  at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0 
  at GLib.SignalClosure.MarshalCallback (IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data) [0x00000] in <filename unknown>:0

Another test
-----------------------
In the test program attached loading the jpg through the Bitmap (filename) constructor causes the following error...

Unhandled Exception: System.ArgumentException: A null reference or invalid value was found [GDI+ status: InvalidParameter]
  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x0009b] in /home/garyb/mono/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs:220 
  at System.Drawing.Bitmap..ctor (System.String filename, Boolean useIcm) [0x00034] in /home/garyb/mono/mcs/class/System.Drawing/System.Drawing/Bitmap.cs:129 
  at System.Drawing.Bitmap..ctor (System.String filename) [0x00000] in /home/garyb/mono/mcs/class/System.Drawing/System.Drawing/Bitmap.cs:106 
  at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (string)
  at ResxTryOuts.MainClass.JpgTest () [0x0000d] in /home/garyb/MDProjects/ResxTryOuts/ResxTryOuts/Main.cs:38 
  at ResxTryOuts.MainClass.Main (System.String[] args) [0x0000b] in /home/garyb/MDProjects/ResxTryOuts/ResxTryOuts/Main.cs:17 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: A null reference or invalid value was found [GDI+ status: InvalidParameter]
  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x0009b] in /home/garyb/mono/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs:220 
  at System.Drawing.Bitmap..ctor (System.String filename, Boolean useIcm) [0x00034] in /home/garyb/mono/mcs/class/System.Drawing/System.Drawing/Bitmap.cs:129 
  at System.Drawing.Bitmap..ctor (System.String filename) [0x00000] in /home/garyb/mono/mcs/class/System.Drawing/System.Drawing/Bitmap.cs:106 
  at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (string)
  at ResxTryOuts.MainClass.JpgTest () [0x0000d] in /home/garyb/MDProjects/ResxTryOuts/ResxTryOuts/Main.cs:38 
  at ResxTryOuts.MainClass.Main (System.String[] args) [0x0000b] in /home/garyb/MDProjects/ResxTryOuts/ResxTryOuts/Main.cs:17 

Icon Corruption
------------------
The icon attached also has problems as demonstrated in the test program and also in my app. On writing out it gets corrupted and loses a lot of bytes.

Are there are inherent limitations / difficulties with image handling on mono / Linux?
Comment 1 Gary____ 2012-08-07 13:28:19 UTC
Created attachment 2318 [details]
jpg causes errors
Comment 2 Gary____ 2012-08-07 13:29:29 UTC
Created attachment 2319 [details]
ico corrupts

both images copyright their respective owners
Comment 3 Gary____ 2012-08-09 12:20:32 UTC
The jpeg issue was resolved by recompiling libgdiplus taking care to ensure correct image format dev packages where available. The Icon corruption remains though.
Comment 4 Gary____ 2012-10-11 07:17:35 UTC
Patch provided and accepted