Пример #1
0
        public void Disposing_Cloned_Bitmap_DoesNot_Harm_Cloned_Bitmap()
        {
            Bitmap bitmap1;
            Bitmap bitmap2;

            using (var image = new WinFormsImage(100, 100))
            {
                image.Render(3, false, false, 0);

                //  acquire cloned bitmap #1.
                bitmap1 = image.AsClonedBitmap();

                //  acquire cloned bitmap #2.
                bitmap2 = image.AsClonedBitmap();
            }

            //  cloned bitmap #1 should be in good shape.
            Assert.Equal(100, bitmap1.Width);

            //  cloned bitmap #2 should be in good shape.
            Assert.Equal(100, bitmap2.Width);

            //  dispose cloned bitmap #1
            bitmap1.Dispose();

            //  cloned bitmap #2 should be still in good shape.
            Assert.Equal(100, bitmap2.Width);
        }
Пример #2
0
        public void As_RawImage_Throws()
        {
            var image = new WinFormsImage(100, 100);

            image.Render(3, false, false, 0);
            Assert.Throws <DicomImagingException>(() => image.As <RawImage>());
        }
Пример #3
0
        [Fact(Skip = "Re-enable when ImageSharp strong names their assemblies")] // TODO re-enable this
        public void As_Image_ReturnsImage()
        {
            var image = new WinFormsImage(100, 100);

            image.Render(3, false, false, 0);
            Assert.IsAssignableFrom <Image>(image.As <Image>());
        }
Пример #4
0
        public void Disposing_WinFormsImage_DoesNot_Harm_Cloned_Bitmap()
        {
            Bitmap bitmap;

            using (var image = new WinFormsImage(100, 100))
            {
                //  render and acquire cloned bitmap
                image.Render(3, false, false, 0);
                bitmap = image.AsClonedBitmap();
            }

            //  cloned bitmap should be in good shape after disposing WinFormsImage.
            Assert.Equal(100, bitmap.Width);
        }
Пример #5
0
        public void Disposing_Cloned_Bitmap_DoesNot_Harm_WinFormsImage()
        {
            Bitmap bitmap;

            using (var image = new WinFormsImage(100, 100))
            {
                image.Render(3, false, false, 0);

                //  acquire cloned bitmap #1, dispose immediately.
                using (image.AsClonedBitmap()) { }

                //  acquire cloned bitmap #2. must not fail.
                bitmap = image.AsClonedBitmap();
            }

            //  bitmap #2 should be in good shape.
            Assert.Equal(100, bitmap.Width);
        }
Пример #6
0
 public void As_ImageSource_Throws()
 {
     var image = new WinFormsImage(100, 100);
     image.Render(3, false, false, 0);
     Assert.Throws(typeof(DicomImagingException), () => image.As<ImageSource>());
 }
Пример #7
0
 public void As_Image_ReturnsImage()
 {
     var image = new WinFormsImage(100, 100);
     image.Render(3, false, false, 0);
     Assert.IsAssignableFrom<Image>(image.As<Image>());
 }