+2004-03-31 Jordi Mas i Hernadez <jordi@ximian.com>
+ * FrameDimension.cs: added missing members
+
2004-03-26 Jordi Mas i Hernadez <jordi@ximian.com>
* ImageAttributes.cs: added missing members and complete the wrapper
// Author: Christian Meyer\r
// eMail: Christian.Meyer@cs.tum.edu\r
// Dennis Hayes (dennish@raytek.com)\r
-// Sanjay Gupta <gsanjay@novell.com)\r
-//\r
+// Sanjay Gupta <gsanjay@novell.com>\r
+// Jordi Mas i Hernanez (jordi@ximian.com)\r
\r
namespace System.Drawing.Imaging {\r
\r
public sealed class FrameDimension {\r
\r
internal Guid guid;\r
+ \r
// constructor\r
- public FrameDimension (Guid guid) \r
+ public FrameDimension(Guid guid) \r
{\r
this.guid = guid;\r
}\r
\r
public static FrameDimension Page {\r
get {\r
- return new FrameDimension ( new Guid ( "7462dc86-6180-4c7e-8e3f-ee7333a7a483" ) );\r
+ return new FrameDimension (new Guid ("7462dc86-6180-4c7e-8e3f-ee7333a7a483"));\r
}\r
}\r
\r
public static FrameDimension Resolution {\r
get {\r
- return new FrameDimension ( new Guid ( "84236f7b-3bd3-428f-8dab-4ea1439ca315" ) ); \r
+ return new FrameDimension (new Guid ("84236f7b-3bd3-428f-8dab-4ea1439ca315" )); \r
}\r
}\r
\r
public static FrameDimension Time {\r
get {\r
- return new FrameDimension ( new Guid ( "6aedbd6d-3fb5-418a-83a6-7f45229dc872" ) ); \r
+ return new FrameDimension (new Guid ("6aedbd6d-3fb5-418a-83a6-7f45229dc872" )); \r
}\r
}\r
\r
- //methods\r
- public override bool Equals (object o) {\r
- throw new NotImplementedException ();\r
+ //methods\r
+ public override bool Equals(object o) \r
+ {\r
+ if (!(o is FrameDimension))\r
+ return false; \r
+ \r
+ return (guid == ((FrameDimension)o).guid); \r
}\r
\r
- public override int GetHashCode () {\r
- throw new NotImplementedException ();\r
+ public override int GetHashCode() \r
+ {\r
+ return guid.GetHashCode ();\r
}\r
\r
- public override string ToString() {\r
- throw new NotImplementedException ();\r
+ public override string ToString() \r
+ {\r
+ return "FrameDimension :" + guid;\r
}\r
\r
//destructor\r
- ~FrameDimension () {}\r
+ ~FrameDimension() \r
+ {\r
+ \r
+ }\r
}\r
}\r
System.GC.SuppressFinalize (this);
}
- ~ImageAttributes() {
+ ~ImageAttributes()
+ {
Dispose (false);
}
- [MonoTODO]
- object ICloneable.Clone()
- {
- throw new NotImplementedException ();
- }
public object Clone()
+2004-03-30 Jordi Mas i Hernandez <jordi@ximian.com>
+ * Image.cs: implemented a few GDI+ wrapper calls
2004-03-30 Jordi Mas i Hernandez <jordi@ximian.com>
* Bitmap.cs: remove redundant data already present at Image.cs
* Image.cs: use GDI+ functions to get image details
public int GetFrameCount(FrameDimension dimension)
{
- throw new NotImplementedException ();
+ int count;
+ Guid guid = dimension.Guid;
+
+ Status status = GDIPlus.GdipImageGetFrameCount (nativeObject, ref guid, out count);
+ GDIPlus.CheckStatus (status);
+
+ return count;
+
}
[MonoTODO]
Marshal.FreeHGlobal (gdipalette);
}
- [MonoTODO]
+ [MonoTODO ("Ignoring EncoderParameters")]
public void Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
{
- throw new NotImplementedException ();
+ encoder.encode(this, stream);
}
- [MonoTODO]
+ [MonoTODO ("Ignoring EncoderParameters")]
public void Save(string filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
{
- throw new NotImplementedException ();
+ FileStream fs = new FileStream (filename, FileMode.Create);
+ encoder.encode(this, fs);
+ fs.Flush();
+ fs.Close();
+
}
[MonoTODO]
throw new NotImplementedException ();
}
- [MonoTODO]
+
public int SelectActiveFrame(FrameDimension dimension, int frameIndex)
{
- throw new NotImplementedException ();
+ Guid guid = dimension.Guid;
+
+ Status status = GDIPlus.GdipImageSelectActiveFrame (nativeObject, ref guid, frameIndex);
+ GDIPlus.CheckStatus (status);
+
+ return frameIndex;
}
[MonoTODO]
throw new NotImplementedException ();
}
- // properties
- [MonoTODO]
+ // properties
public int Flags {
get {
- throw new NotImplementedException ();
+ int flags;
+
+ Status status = GDIPlus.GdipGetImageFlags (nativeObject, out flags);
+ GDIPlus.CheckStatus (status);
+ return flags;
}
}
return colorPalette;
}
set {
- colorPalette = value;
-
+ colorPalette = value;
}
}
Status status = GDIPlus.GdipGetImageDimension (nativeObject, out width, out height);
GDIPlus.CheckStatus (status);
- return new SizeF(width, height);
+ return new SizeF (width, height);
}
}
}
}
- [MonoTODO]
- object ICloneable.Clone()
- {
- throw new NotImplementedException ();
- }
-
public virtual object Clone()
- {
+ {
IntPtr newimage = IntPtr.Zero;
if (!(this is Bitmap))
GDIPlus.CheckStatus (status);
- if (!(this is Bitmap))
+ if (this is Bitmap)
return new Bitmap (newimage);
throw new NotImplementedException ();
internal static extern Status GdipDisposeImage ( IntPtr image );
[DllImport("gdiplus.dll")]
- internal static extern Status GdipGetImageFlags ( IntPtr image, out uint flag );
+ internal static extern Status GdipGetImageFlags(IntPtr image, out int flag);
[DllImport("gdiplus.dll")]
internal static extern Status GdipImageGetFrameDimensionsCount ( IntPtr image, out uint count );
internal static extern Status GdipImageGetFrameCount (IntPtr image, ref Guid guidDimension, out int count );
[DllImport("gdiplus.dll")]
- internal static extern Status GdipImageSelectActiveFrame ( IntPtr image, ref Guid guidDimension, uint frameIndex );
+ internal static extern Status GdipImageSelectActiveFrame (IntPtr image, ref Guid guidDimension, int frameIndex);
[DllImport("gdiplus.dll")]
internal static extern Status GdipGetPropertyItemSize ( IntPtr image, int propertyID, out uint propertySize );
AssertEquals (colororg50, colornew50);
}
+ [Test]
+ public void CloneImage()
+ {
+ string sInFile = getInFile ("bitmaps/almogaver24bits.bmp");
+ Bitmap bmp = new Bitmap(sInFile);
+
+ Bitmap bmpNew = (Bitmap) bmp.Clone ();
+
+ AssertEquals (bmp.Width, bmpNew.Width);
+ AssertEquals (bmp.Height, bmpNew.Height);
+ AssertEquals (bmp.PixelFormat, bmpNew.PixelFormat);
+
+ }
+
/* Check bitmap features on a know 24-bits bitmap*/
[Test]
public void BitmapFeatures()
AssertEquals (173, bmp.Size.Width);
AssertEquals (183, bmp.Size.Height);
}
-
+
+ [Test]
+ public void Frames()
+ {
+ string sInFile = getInFile ("bitmaps/almogaver24bits.bmp");
+ Bitmap bmp = new Bitmap(sInFile);
+ int cnt = bmp.GetFrameCount(FrameDimension.Page);
+ int active = bmp.SelectActiveFrame (FrameDimension.Page, 0);
+
+ AssertEquals (1, cnt);
+ AssertEquals (0, active);
+
+ }
}
}
public static void Main(string[] argv) {
if( argv.Length == 1) {
Bitmap bmp = new Bitmap(argv[0]);
- bmp.Save(argv[0] + ".bmp", ImageFormat.Bmp);
+
Console.WriteLine("Output file " + argv[0] + ".bmp");
+ bmp.Save("output.bmp", ImageFormat.Bmp);
+
}
else {
Console.WriteLine("usage: image1.exe <filename>");