Fixes MakeTransparent method
[mono.git] / mcs / class / System.Drawing / System.Drawing / gdipStructs.cs
index ae0250dde18a41c95eb4bb2e2759e91f1bf3665e..101fbf575b33127298e29ad634afe7c66f0a9b1f 100644 (file)
@@ -6,6 +6,29 @@
 // Jordi Mas (jordi@ximian.com)
 //
 
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
 using System;
 using System.Runtime.InteropServices;
 using System.Text;
@@ -99,30 +122,18 @@ namespace System.Drawing
                IntPtr SigPattern;
                IntPtr SigMask;
                
-               internal static void MarshalTo (GdipImageCodecInfo gdipcodec, ImageCodecInfo codec)
-               {
-                       // FIXME: See run-time bug 57706. When fixed, we should be able to remove the if(s)                     
-                       if (gdipcodec.CodecName != IntPtr.Zero)
-                               codec.CodecName = Marshal.PtrToStringUni (gdipcodec.CodecName);                                                 
-                       
-                       if (gdipcodec.DllName != IntPtr.Zero)
-                               codec.DllName = Marshal.PtrToStringUni (gdipcodec.DllName);
-                       
-                       if (gdipcodec.FormatDescription != IntPtr.Zero)
-                               codec.FormatDescription = Marshal.PtrToStringUni (gdipcodec.FormatDescription);
-                       
-                       if (gdipcodec.FilenameExtension != IntPtr.Zero)                         
-                               codec.FilenameExtension = Marshal.PtrToStringUni (gdipcodec.FilenameExtension);
-                       
-                       if (gdipcodec.MimeType != IntPtr.Zero)                          
-                               codec.MimeType = Marshal.PtrToStringUni (gdipcodec.MimeType);
-                       
-                       codec.Clsid = gdipcodec.Clsid;
-                       codec.FormatID = gdipcodec.FormatID;                    
-                       codec.Flags = gdipcodec.Flags;
-                       codec.Version  = gdipcodec.Version;             
-                       
-               }
+               internal static void MarshalTo (GdipImageCodecInfo gdipcodec, ImageCodecInfo codec)
+               {       
+                       codec.CodecName = Marshal.PtrToStringUni (gdipcodec.CodecName);                                                 
+                       codec.DllName = Marshal.PtrToStringUni (gdipcodec.DllName);
+                       codec.FormatDescription = Marshal.PtrToStringUni (gdipcodec.FormatDescription);
+                       codec.FilenameExtension = Marshal.PtrToStringUni (gdipcodec.FilenameExtension);
+                       codec.MimeType = Marshal.PtrToStringUni (gdipcodec.MimeType);
+                       codec.Clsid = gdipcodec.Clsid;
+                       codec.FormatID = gdipcodec.FormatID;                    
+                       codec.Flags = gdipcodec.Flags;
+                       codec.Version  = gdipcodec.Version;                                     
+               }
        }
 
        [StructLayout(LayoutKind.Sequential)]
@@ -132,5 +143,23 @@ namespace System.Drawing
                internal EncoderParameterValueType type;
                internal IntPtr value;
        }
+
+       [StructLayout(LayoutKind.Sequential)]
+       internal struct GdipPropertyItem
+       {
+               internal int id;
+               internal int len;
+               internal short type;
+               internal IntPtr value;
+
+               internal static void MarshalTo (GdipPropertyItem gdipProp, PropertyItem prop)
+               {       
+                       prop.Id = gdipProp.id;
+                       prop.Len = gdipProp.len;
+                       prop.Type = gdipProp.type;
+                       prop.Value = new byte [gdipProp.len];                   
+                       Marshal.Copy (gdipProp.value, prop.Value, 0, gdipProp.len);
+               }
+       }
 }