[Category("NotWorking")] // https://bugzilla.novell.com/show_bug.cgi?id=338779 public void FromStream_Metafile_Wmf_NotOrigin() { Assert.Throws <ArgumentException>(() => { string filename = TestBitmap.getInFile("bitmaps/telescope_01.wmf"); using (FileStream fs = File.OpenRead(filename)) { fs.Position = fs.Length / 2; Image.FromStream(fs); } }); }
public void SelectFromUnusualSize_Normal32() { using (FileStream fs = File.OpenRead(TestBitmap.getInFile("bitmaps/80509.ico"))) { using (Icon xp = new Icon(fs, 32, 32)) { Assert.AreEqual(22, xp.Height, "Height"); Assert.AreEqual(11, xp.Width, "Width"); Assert.AreEqual(11, xp.Size.Width, "Size.Width"); Assert.AreEqual(22, xp.Size.Height, "Size.Height"); } } }
public void FromStream_Metafile_Wmf() { string filename = TestBitmap.getInFile("bitmaps/telescope_01.wmf"); using (FileStream fs = File.OpenRead(filename)) { using (Image img = Image.FromStream(fs)) { Wmf(img); } } }
public void FromStream_Metafile_Emf() { string filename = TestBitmap.getInFile("bitmaps/milkmateya01.emf"); using (FileStream fs = File.OpenRead(filename)) { using (Image img = Image.FromStream(fs)) { Emf(img); } } }
public void SetUp() { String path = TestBitmap.getInFile("bitmaps/smiley.ico"); icon = new Icon(path); fs1 = new FileStream(path, FileMode.Open); icon16 = new Icon(TestBitmap.getInFile("bitmaps/16x16x16.ico")); icon32 = new Icon(TestBitmap.getInFile("bitmaps/32x32x16.ico")); icon48 = new Icon(TestBitmap.getInFile("bitmaps/48x48x1.ico")); icon64 = new Icon(TestBitmap.getInFile("bitmaps/64x64x256.ico")); icon96 = new Icon(TestBitmap.getInFile("bitmaps/96x96x256.ico")); }
public void Icon256ToBitmap_Request0() { // 415581.ico has 2 images, the 256 and 48 using (FileStream fs = File.OpenRead(TestBitmap.getInFile("bitmaps/415581.ico"))) { Icon icon = new Icon(fs, 0, 0); using (Bitmap b = icon.ToBitmap()) { Assert.AreEqual(0, b.Palette.Entries.Length, "#B1"); Assert.AreEqual(48, b.Height, "#B2"); Assert.AreEqual(48, b.Width, "#B3"); Assert.IsTrue(b.RawFormat.Equals(ImageFormat.MemoryBmp), "#B4"); Assert.AreEqual(2, b.Flags, "#B5"); } } }
public void Constructor_Icon_DoesntReturn256Passing1() { string filepath = TestBitmap.getInFile("bitmaps/323511.ico"); Icon orig = new Icon(filepath); Assert.AreEqual(32, orig.Height); Assert.AreEqual(32, orig.Width); Icon ret = new Icon(orig, 1, 1); Assert.AreNotEqual(0, ret.Height); Assert.AreNotEqual(0, ret.Width); }
public void Constructor_Icon_GetNormalSizeFromIconWith256() { string filepath = TestBitmap.getInFile("bitmaps/323511.ico"); Icon orig = new Icon(filepath); Assert.AreEqual(32, orig.Height); Assert.AreEqual(32, orig.Width); Icon ret = new Icon(orig, 48, 48); Assert.AreEqual(48, ret.Height); Assert.AreEqual(48, ret.Width); }
[Test] // bug #410608 public void Save_256() { string filepath = TestBitmap.getInFile("bitmaps/323511.ico"); using (Icon icon = new Icon(filepath)) { // bug #415809 fixed SaveAndCompare("256", icon, true); } // binary comparison var orig = new MemoryStream(File.ReadAllBytes(filepath)); var saved = new MemoryStream(); using (Icon icon = new Icon(filepath)) icon.Save(saved); FileAssert.AreEqual(orig, saved, "binary comparison"); }
public void HiconRoundtrip() { IntPtr handle; using (Icon icon = new Icon(TestBitmap.getInFile("bitmaps/16x16x16.ico"))) { Assert.AreEqual(16, icon.Height, "Original.Height"); Assert.AreEqual(16, icon.Width, "Original.Width"); handle = icon.ToBitmap().GetHicon(); } // HICON survives using (Icon icon2 = Icon.FromHandle(handle)) { Assert.AreEqual(16, icon2.Height, "Survivor.Height"); Assert.AreEqual(16, icon2.Width, "Survivor.Width"); Assert.AreEqual(handle, icon2.Handle, "Survivor.Handle"); IconTest.SaveAndCompare("HICON", icon2, false); } }
private void XPIcon(int size) { // note: the Icon(string,Size) or Icon(string,int,int) doesn't exists under 1.x using (FileStream fs = File.OpenRead(TestBitmap.getInFile("bitmaps/32bpp.ico"))) { using (Icon xp = new Icon(fs, size, size)) { Assert.AreEqual(size, xp.Height, "Height"); Assert.AreEqual(size, xp.Width, "Width"); Assert.AreEqual(size, xp.Size.Width, "Size.Width"); Assert.AreEqual(size, xp.Size.Height, "Size.Height"); Bitmap bmp = xp.ToBitmap(); Assert.AreEqual(size, bmp.Height, "Bitmap.Height"); Assert.AreEqual(size, bmp.Width, "Bitmap.Width"); Assert.AreEqual(size, bmp.Size.Width, "Bitmap.Size.Width"); Assert.AreEqual(size, bmp.Size.Height, "Bitmap.Size.Height"); } } }
[Test] // bug #410608 public void Save_256() { if (RunningOnUnix) { Assert.Ignore("Depends on bug #323511"); } using (Icon icon = new Icon(TestBitmap.getInFile("bitmaps/323511.ico"))) { // FIXME: use this instead after bug #415809 is fixed //SaveAndCompare ("256", icon, true); MemoryStream ms = new MemoryStream(); icon.Save(ms); ms.Position = 0; using (Icon loaded = new Icon(ms)) { Assert.AreEqual(icon.Height, loaded.Height, "Loaded.Height"); Assert.AreEqual(icon.Width, loaded.Width, "Loaded.Width"); } } }
public void CreateMultipleIconFromSameHICON() { IntPtr handle; using (Icon icon = new Icon(TestBitmap.getInFile("bitmaps/16x16x16.ico"))) { Assert.AreEqual(16, icon.Height, "Original.Height"); Assert.AreEqual(16, icon.Width, "Original.Width"); handle = icon.ToBitmap().GetHicon(); } // HICON survives using (Icon icon2 = Icon.FromHandle(handle)) { Assert.AreEqual(16, icon2.Height, "2.Height"); Assert.AreEqual(16, icon2.Width, "2.Width"); Assert.AreEqual(handle, icon2.Handle, "2.Handle"); IconTest.SaveAndCompare("HICON2", icon2, false); } using (Icon icon3 = Icon.FromHandle(handle)) { Assert.AreEqual(16, icon3.Height, "3.Height"); Assert.AreEqual(16, icon3.Width, "3.Width"); Assert.AreEqual(handle, icon3.Handle, "3.Handle"); IconTest.SaveAndCompare("HICON", icon3, false); } }
public void HandleRoundtrip() { IntPtr handle; using (Icon icon = new Icon(TestBitmap.getInFile("bitmaps/16x16x16.ico"))) { Assert.AreEqual(16, icon.Height, "Original.Height"); Assert.AreEqual(16, icon.Width, "Original.Width"); handle = icon.Handle; using (Icon icon2 = Icon.FromHandle(handle)) { Assert.AreEqual(16, icon2.Height, "FromHandle.Height"); Assert.AreEqual(16, icon2.Width, "FromHandle.Width"); Assert.AreEqual(handle, icon2.Handle, "FromHandle.Handle"); IconTest.SaveAndCompare("Handle", icon2, false); } } // unlike other cases (HICON, HBITMAP) handle DOESN'T survives original icon disposal // commented / using freed memory is risky ;-) /*using (Icon icon3 = Icon.FromHandle (handle)) { * Assert.AreEqual (0, icon3.Height, "Survivor.Height"); * Assert.AreEqual (0, icon3.Width, "Survivor.Width"); * Assert.AreEqual (handle, icon3.Handle, "Survivor.Handle"); * }*/ }
public void CreateMultipleIconFromSameHandle() { IntPtr handle; using (Icon icon = new Icon(TestBitmap.getInFile("bitmaps/16x16x16.ico"))) { Assert.AreEqual(16, icon.Height, "Original.Height"); Assert.AreEqual(16, icon.Width, "Original.Width"); handle = icon.Handle; using (Icon icon2 = Icon.FromHandle(handle)) { Assert.AreEqual(16, icon2.Height, "2.Height"); Assert.AreEqual(16, icon2.Width, "2.Width"); Assert.AreEqual(handle, icon2.Handle, "2.Handle"); IconTest.SaveAndCompare("Handle2", icon2, false); } using (Icon icon3 = Icon.FromHandle(handle)) { Assert.AreEqual(16, icon3.Height, "3.Height"); Assert.AreEqual(16, icon3.Width, "3.Width"); Assert.AreEqual(handle, icon3.Handle, "3.Handle"); IconTest.SaveAndCompare("Handle3", icon3, false); } } // unlike other cases (HICON, HBITMAP) handle DOESN'T survives original icon disposal // commented / using freed memory is risky ;-) }
[Test, ExpectedException()] //ToDo: System.ComponentModel.Win32Exception public void Only256InFile() { using (FileStream fs = File.OpenRead(TestBitmap.getInFile("bitmaps/only256.ico"))) { Icon icon = new Icon(fs, 0, 0); } }
public void Only256InFile() { using (FileStream fs = File.OpenRead(TestBitmap.getInFile("bitmaps/only256.ico"))) { Assert.Throws <Win32Exception> (() => new Icon(fs, 0, 0)); } }