}
- [MonoTODO]
public PropertyItem GetPropertyItem(int propid)
{
- throw new NotImplementedException ();
+ int propSize;
+ IntPtr property;
+ PropertyItem item = new PropertyItem ();
+ GdipPropertyItem gdipProperty = new GdipPropertyItem ();
+ Status status;
+
+ status = GDIPlus.GdipGetPropertyItemSize (nativeObject, propid,
+ out propSize);
+ GDIPlus.CheckStatus (status);
+
+ /* Get PropertyItem */
+ property = Marshal.AllocHGlobal (propSize);
+ status = GDIPlus.GdipGetPropertyItem (nativeObject, propid, propSize,
+ property);
+ GDIPlus.CheckStatus (status);
+ gdipProperty = (GdipPropertyItem) Marshal.PtrToStructure ((IntPtr)property,
+ typeof (GdipPropertyItem));
+ GdipPropertyItem.MarshalTo (gdipProperty, item);
+
+ Marshal.FreeHGlobal (property);
+ return item;
}
public Image GetThumbnailImage(int thumbWidth, int thumbHeight, Image.GetThumbnailImageAbort callback, IntPtr callbackData)
}
GDIPlus.CheckStatus (st);
}
-
public void SaveAdd (EncoderParameters encoderParams)
{
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)
{
Status st;
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)
{
Guid guid = dimension.Guid;
return frameIndex;
}
- [MonoTODO]
public void SetPropertyItem(PropertyItem propitem)
{
- throw new NotImplementedException ();
+ IntPtr property;
+ int size = Marshal.SizeOf (typeof(GdipPropertyItem));
+ property = Marshal.AllocHGlobal (size);
+
+ Marshal.StructureToPtr (propitem, property, true);
+ Status status = GDIPlus.GdipSetPropertyItem (nativeObject, property);
+ GDIPlus.CheckStatus (status);
}
// properties
uint found;
Status status = GDIPlus.GdipImageGetFrameDimensionsCount (nativeObject, out found);
GDIPlus.CheckStatus (status);
- Guid [] guid = new Guid [found ];
+ Guid [] guid = new Guid [found];
status = GDIPlus.GdipImageGetFrameDimensionsList (nativeObject, guid, found);
GDIPlus.CheckStatus (status);
return guid;
colorPalette = value;
}
}
-
-
+
public SizeF PhysicalDimension {
get {
float width, height;
}
}
-
- [MonoTODO]
[Browsable (false)]
public int[] PropertyIdList {
get {
- throw new NotImplementedException ();
+ uint propNumbers;
+
+ Status status = GDIPlus.GdipGetPropertyCount (nativeObject,
+ out propNumbers);
+ GDIPlus.CheckStatus (status);
+
+ int [] idList = new int [propNumbers];
+ status = GDIPlus.GdipGetPropertyIdList (nativeObject,
+ propNumbers, idList);
+ GDIPlus.CheckStatus (status);
+
+ return idList;
}
}
- [MonoTODO]
[Browsable (false)]
public PropertyItem[] PropertyItems {
get {
- throw new NotImplementedException ();
+ int propNums, propsSize, propSize;
+ IntPtr properties, propPtr;
+ PropertyItem[] items;
+ GdipPropertyItem gdipProperty = new GdipPropertyItem ();
+ Status status;
+
+ status = GDIPlus.GdipGetPropertySize (nativeObject, out propsSize, out propNums);
+ GDIPlus.CheckStatus (status);
+
+ items = new PropertyItem [propNums];
+
+ if (propNums == 0)
+ return items;
+
+ /* Get PropertyItem list*/
+ properties = Marshal.AllocHGlobal (propsSize);
+ status = GDIPlus.GdipGetAllPropertyItems (nativeObject, propsSize,
+ propNums, properties);
+ GDIPlus.CheckStatus (status);
+
+ propSize = Marshal.SizeOf (gdipProperty);
+ propPtr = properties;
+
+ for (int i = 0; i < propNums; i++, propPtr = new IntPtr (propPtr.ToInt64 () + propSize))
+ {
+ gdipProperty = (GdipPropertyItem) Marshal.PtrToStructure
+ (propPtr, typeof (GdipPropertyItem));
+ items [i] = new PropertyItem ();
+ GdipPropertyItem.MarshalTo (gdipProperty, items [i]);
+ }
+
+ Marshal.FreeHGlobal (properties);
+ return items;
}
}
public void Dispose ()
{
Dispose (true);
+ System.GC.SuppressFinalize (this);
}
~Image ()
protected virtual void Dispose (bool disposing)
{
- if (nativeObject != (IntPtr) 0){
+ if (nativeObject != IntPtr.Zero){
DisposeResources ();
- nativeObject=IntPtr.Zero;
+ nativeObject = IntPtr.Zero;
}
}
-
public virtual object Clone()
{
lock (this)
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 ();
}