Ejemplo n.º 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);
        }
Ejemplo n.º 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>());
        }
Ejemplo n.º 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>());
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }