Author: jordi
Date: 2005-03-23 04:40:43 -0500 (Wed, 23 Mar 2005)
New Revision: 42133
Modified:
trunk/mcs/class/System.Drawing/System.Drawing.Imaging/ChangeLog
trunk/mcs/class/System.Drawing/System.Drawing.Imaging/ColorPalette.cs
trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog
trunk/mcs/class/System.Drawing/System.Drawing/Image.cs
trunk/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs
Log:
In System.Drawing.Imaging:
2005-03-23 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
* ColorPalette.cs: fixes ColorPalette marshaling
In System.Drawing:
2005-03-23 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
* gdipFunctions.cs: fixes GdipGetImagePalette signature
* Image.cs: Implements Palette property using gdiplus
Modified: trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog 2005-03-23
08:19:41 UTC (rev 42132)
+++ trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog 2005-03-23
09:40:43 UTC (rev 42133)
@@ -1,3 +1,8 @@
+2005-03-23 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+
+ * gdipFunctions.cs: fixes GdipGetImagePalette signature
+ * Image.cs: Implements Palette property using gdiplus
+
2005-03-17 Peter Bartok <[EMAIL PROTECTED]>
* gdipFunctions.cs:
Modified: trunk/mcs/class/System.Drawing/System.Drawing/Image.cs
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/Image.cs 2005-03-23
08:19:41 UTC (rev 42132)
+++ trunk/mcs/class/System.Drawing/System.Drawing/Image.cs 2005-03-23
09:40:43 UTC (rev 42133)
@@ -54,13 +54,12 @@
public delegate bool GetThumbnailImageAbort();
internal IntPtr nativeObject = IntPtr.Zero;
- ColorPalette colorPalette;
// constructor
internal Image()
- {
- colorPalette = new ColorPalette();
+ {
+
}
private Image (SerializationInfo info, StreamingContext context)
@@ -497,11 +496,42 @@
[Browsable (false)]
public ColorPalette Palette {
get {
+ int size = 0;
+ IntPtr palbuff;
- return colorPalette;
+ Status status = GDIPlus.GdipGetImagePaletteSize
(nativeObject, out size);
+ GDIPlus.CheckStatus (status);
+
+ palbuff = Marshal.AllocHGlobal (size);
+
+ try {
+ Console.WriteLine ("point 2->{0}", size);
+ status = GDIPlus.GdipGetImagePalette
(nativeObject, palbuff, size);
+ GDIPlus.CheckStatus (status);
+
+ ColorPalette colpal = new ColorPalette ();
+ colpal.setFromGDIPalette (palbuff);
+
+ return colpal;
+ }
+
+ finally {
+ Marshal.FreeHGlobal (palbuff);
+ }
+
}
set {
- colorPalette = value;
+ IntPtr palbuff = value.getGDIPalette ();
+
+ try {
+ Status status = GDIPlus.GdipSetImagePalette
(nativeObject, palbuff);
+ GDIPlus.CheckStatus (status);
+ }
+
+ finally {
+ Marshal.FreeHGlobal (palbuff);
+ }
+
}
}
@@ -672,12 +702,7 @@
GDIPlus.CheckStatus (status);
if (this is Bitmap){
- Bitmap b = new Bitmap (newimage);
-
- if (colorPalette != null)
- b.colorPalette = colorPalette.Clone ();
-
- return b;
+ return new Bitmap (newimage);
}
throw new NotImplementedException ();
Modified: trunk/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs
2005-03-23 08:19:41 UTC (rev 42132)
+++ trunk/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs
2005-03-23 09:40:43 UTC (rev 42133)
@@ -935,7 +935,7 @@
internal static extern Status GdipGetImagePaletteSize ( IntPtr
image, out int size );
[DllImport("gdiplus.dll")]
- internal static extern Status GdipGetImagePalette (IntPtr
image, out IntPtr palette, int size);
+ internal static extern Status GdipGetImagePalette (IntPtr
image, IntPtr palette, int size);
[DllImport("gdiplus.dll")]
internal static extern Status GdipSetImagePalette (IntPtr
image, IntPtr palette);
Modified: trunk/mcs/class/System.Drawing/System.Drawing.Imaging/ChangeLog
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing.Imaging/ChangeLog
2005-03-23 08:19:41 UTC (rev 42132)
+++ trunk/mcs/class/System.Drawing/System.Drawing.Imaging/ChangeLog
2005-03-23 09:40:43 UTC (rev 42133)
@@ -1,3 +1,7 @@
+2005-03-23 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+
+ * ColorPalette.cs: fixes ColorPalette marshaling
+
2004-03-21 Jordi Mas i Hernadez <[EMAIL PROTECTED]>
* ColorMatrix.cs: fixes Matrix00 init
Modified: trunk/mcs/class/System.Drawing/System.Drawing.Imaging/ColorPalette.cs
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing.Imaging/ColorPalette.cs
2005-03-23 08:19:41 UTC (rev 42132)
+++ trunk/mcs/class/System.Drawing/System.Drawing.Imaging/ColorPalette.cs
2005-03-23 09:40:43 UTC (rev 42133)
@@ -86,33 +86,30 @@
int[] values = new int[palette.Count];
for (int i = 0; i < values.Length; i++) {
- values[i] = entries[i].ToArgb();
- //Console.Write("{0:X} ;", values[i]);
- }
+ values[i] = entries[i].ToArgb();
+ }
- //Console.WriteLine("pal size " + Marshal.SizeOf
(palette) + " native " + NativeObject);
-
Marshal.StructureToPtr (palette, lfBuffer, false);
- Marshal.Copy (values, 0, (IntPtr) (lfBuffer.ToInt32() +
Marshal.SizeOf (palette)), values.Length);
+ Marshal.Copy (values, 0, (IntPtr) (lfBuffer.ToInt32() +
Marshal.SizeOf (palette)), values.Length);
return lfBuffer;
}
-
- internal ColorPalette Clone ()
+
+ internal void setFromGDIPalette (IntPtr palette)
{
- ColorPalette clone = new ColorPalette ();
+ IntPtr ptr = palette;
+ int cnt, color;
- clone.flags = flags;
- clone.entries = new Color [entries.Length];
- for (int i = 0; i < entries.Length; i++)
- clone.entries [i] = entries [i];
-
- return clone;
+ flags = Marshal.ReadInt32 (ptr); ptr = (IntPtr)
(ptr.ToInt32() + 4);
+ cnt = Marshal.ReadInt32 (ptr); ptr = (IntPtr)
(ptr.ToInt32() + 4);
+
+ entries = new Color [cnt];
+
+ for (int i = 0; i < cnt; i++) {
+ color = Marshal.ReadInt32 (ptr);
+ entries[i] = Color.FromArgb (color);
+ ptr = (IntPtr) (ptr.ToInt32() + 4);
+ }
}
-
- internal void setFromGDIPalette(IntPtr palette)
- {
-
- }
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches