コード例 #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_ImageSource_Throws()
        {
            var image = new WinFormsImage(100, 100);

            image.Render(3, false, false, 0);
            Assert.Throws <DicomImagingException>(() => image.As <ImageSource>());
        }
コード例 #3
0
        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);
        }