2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / System.Drawing / System.Drawing / Image.cs
index 264b8d5754ef5dce02f9d26b306346e08fb7e385..0bfe5c94215db1102aa933a9f7fc273a76e13048 100644 (file)
@@ -409,7 +409,8 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
                
                IntPtr nativeEncoderParams = encoderParams.ToNativePtr ();
                st = GDIPlus.GdipSaveAdd (nativeObject, nativeEncoderParams);
-               Marshal.FreeHGlobal (nativeEncoderParams);
+               Marshal.FreeHGlobal (nativeEncoderParams);\r
+               GDIPlus.CheckStatus (st);
        }
                
        public void SaveAdd (Image image, EncoderParameters encoderParams)
@@ -418,7 +419,8 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
                
                IntPtr nativeEncoderParams = encoderParams.ToNativePtr ();
                st = GDIPlus.GdipSaveAddImage (nativeObject, image.NativeObject, nativeEncoderParams);
-               Marshal.FreeHGlobal (nativeEncoderParams);
+               Marshal.FreeHGlobal (nativeEncoderParams);\r
+               GDIPlus.CheckStatus (st);
        }
                
        public int SelectActiveFrame(FrameDimension dimension, int frameIndex)
@@ -543,8 +545,8 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
        [Browsable (false)]
        public PropertyItem[] PropertyItems {
                get {
-                       int propNums, propsSize, propPtr, propSize;
-                       IntPtr properties;
+                       int propNums, propsSize, propSize;
+                       IntPtr properties, propPtr;
                        PropertyItem[] items;
                        GdipPropertyItem gdipProperty = new GdipPropertyItem ();
                        Status status;
@@ -564,12 +566,12 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
                        GDIPlus.CheckStatus (status);
 
                        propSize = Marshal.SizeOf (gdipProperty);                       
-                       propPtr = properties.ToInt32();
+                       propPtr = properties;
                        
-                       for (int i = 0; i < propNums; i++, propPtr += propSize)
+                       for (int i = 0; i < propNums; i++, propPtr = new IntPtr (propPtr.ToInt64 () + propSize))
                        {
                                gdipProperty = (GdipPropertyItem) Marshal.PtrToStructure 
-                                               ((IntPtr)propPtr, typeof (GdipPropertyItem));                                           
+                                               (propPtr, typeof (GdipPropertyItem));                                           
                                items [i] = new PropertyItem ();
                                GdipPropertyItem.MarshalTo (gdipProperty, items [i]);                                                           
                        }
@@ -666,11 +668,16 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
                                throw new NotImplementedException (); 
                        
                        Status status = GDIPlus.GdipCloneImage (NativeObject, out newimage);                    
-                       
                        GDIPlus.CheckStatus (status);                   
-                       
-                       if (this is Bitmap)
-                               return new Bitmap (newimage);
+
+                       if (this is Bitmap){
+                               Bitmap b = new Bitmap (newimage);
+
+                               if (colorPalette != null)
+                                       b.colorPalette = colorPalette.Clone ();
+
+                               return b;
+                       }
                        
                        throw new NotImplementedException (); 
                }