示例#1
0
        public void NewAndDelete()
        {
            int width  = 21;
            int height = 128;

            var images = new ImageList();
            int count  = images.Count;

            var image = new Image(width, height, ImageBaseType.Rgb)
            {
                { new Layer("test", ImageType.Rgb), 0 }
            };

            Assert.AreEqual(count, images.Count);

            var display = new Display(image);

            images.Refresh();
            Assert.AreEqual(count + 1, images.Count);

            display.Delete();
            images.Refresh();

            /// Todo: the next assert fails! The number of images is still the same.
            Assert.AreEqual(count, images.Count);
            image.Delete();
        }
示例#2
0
        public void NewIndexedImage()
        {
            var image = new Image(_width, _height, ImageBaseType.Indexed);

            Assert.AreEqual(ImageBaseType.Indexed, image.BaseType);
            image.Delete();
        }
示例#3
0
        public void DirectAccessRgba()
        {
            var image = new Image(_width, _height, ImageBaseType.Rgb)
            {
                { new Layer("test", ImageType.Rgba), 0 }
            };

            var drawable = image.ActiveDrawable;
            var pixel    = new Pixel(13, 24, 35, 128);

            FillDrawable(drawable, pixel);

            var rgn = new PixelRgn(drawable, false, false);

            for (IntPtr pr = PixelRgn.Register(rgn); pr != IntPtr.Zero;
                 pr = PixelRgn.Process(pr))
            {
                for (int y = rgn.Y; y < rgn.Y + rgn.H; y++)
                {
                    for (int x = rgn.X; x < rgn.X + rgn.W; x++)
                    {
                        Assert.AreEqual(pixel.Color, rgn[y, x].Color);
                    }
                }
            }
            image.Delete();
        }
示例#4
0
 public void AddConstructor()
 {
     var image = new Image(_width, _height, ImageBaseType.Rgb) {
     {new Layer("test", ImageType.Rgb), 0}};
       Assert.AreEqual(1, image.Layers.Count);
       image.Delete();
 }
示例#5
0
        public void NewGrayImage()
        {
            var image = new Image(_width, _height, ImageBaseType.Gray);

            Assert.AreEqual(ImageBaseType.Gray, image.BaseType);
            image.Delete();
        }
示例#6
0
        public void Duplicate()
        {
            var copy = new Image(_image);

            Assert.AreEqual(_image.Width, copy.Width);
            Assert.AreEqual(_image.Height, copy.Height);
            Assert.AreEqual(_image.BaseType, copy.BaseType);
            copy.Delete();
        }
示例#7
0
        public void AddConstructor()
        {
            var image = new Image(_width, _height, ImageBaseType.Rgb)
            {
                { new Layer("test", ImageType.Rgb), 0 }
            };

            Assert.AreEqual(1, image.Layers.Count);
            image.Delete();
        }
示例#8
0
        public void CopyRgb2Rgba()
        {
            // Fill src region

            var pixel = new Pixel(13, 24, 35);

            FillDrawable(_drawable, pixel);

            // Copy to dest region
            var image = new Image(_width, _height, ImageBaseType.Rgb)
            {
                { new Layer("test", ImageType.Rgba), 0 }
            };
            var drawable = image.ActiveDrawable;

            var srcRgn  = new PixelRgn(_drawable, false, false);
            var destRgn = new PixelRgn(drawable, true, false);

            for (IntPtr pr = PixelRgn.Register(srcRgn, destRgn); pr != IntPtr.Zero;
                 pr = PixelRgn.Process(pr))
            {
                for (int y = srcRgn.Y; y < srcRgn.Y + srcRgn.H; y++)
                {
                    for (int x = srcRgn.X; x < srcRgn.X + srcRgn.W; x++)
                    {
                        var tmp = srcRgn[y, x];
                        destRgn[y, x] = new Pixel(tmp.Red, tmp.Green, tmp.Blue, 255);
                    }
                }
            }

            // Check results

            var pixel2 = new Pixel(13, 24, 35, 255);

            srcRgn  = new PixelRgn(_drawable, false, false);
            destRgn = new PixelRgn(drawable, false, false);
            for (IntPtr pr = PixelRgn.Register(srcRgn, destRgn); pr != IntPtr.Zero;
                 pr = PixelRgn.Process(pr))
            {
                for (int y = srcRgn.Y; y < srcRgn.Y + srcRgn.H; y++)
                {
                    for (int x = srcRgn.X; x < srcRgn.X + srcRgn.W; x++)
                    {
                        Assert.AreEqual(pixel.Color, srcRgn[y, x].Color);
                        Assert.AreEqual(pixel2.Color, destRgn[y, x].Color);
                    }
                }
            }
            image.Delete();
        }
示例#9
0
        public void IsValid()
        {
            int width = 21;
              int height = 128;

              var image = new Image(width, height, ImageBaseType.Rgb) {
            {new Layer("test", ImageType.Rgb), 0}};

              var display = new Display(image);
              Assert.IsTrue(display.Valid);

              display.Delete();
              image.Delete();
              Display.DisplaysFlush();
              Assert.IsFalse(display.Valid);
        }
示例#10
0
        public void ConstructorFour()
        {
            var layer = new Layer(_image, "test", ImageType.Rgb);

            _image.InsertLayer(layer, 0);

            var image = new Image(_width, _height, ImageBaseType.Rgb);

            layer = new Layer(_image, image, "new_from_visible");
            image.InsertLayer(layer, 0);

            Assert.AreEqual(1, image.Layers.Count);
            Assert.AreEqual(image.Width, layer.Width);
            Assert.AreEqual(image.Height, layer.Height);
            Assert.AreEqual(100, layer.Opacity);
            Assert.AreEqual(LayerModeEffects.Normal, layer.Mode);

            image.Delete();
        }
示例#11
0
        public void IsValid()
        {
            int width  = 21;
            int height = 128;

            var image = new Image(width, height, ImageBaseType.Rgb)
            {
                { new Layer("test", ImageType.Rgb), 0 }
            };

            var display = new Display(image);

            Assert.IsTrue(display.Valid);

            display.Delete();
            image.Delete();
            Display.DisplaysFlush();
            Assert.IsFalse(display.Valid);
        }
示例#12
0
        public void NewAndDelete()
        {
            int width = 21;
              int height = 128;

              var images = new ImageList();
              int count = images.Count;

              var image = new Image(width, height, ImageBaseType.Rgb) {
            {new Layer("test", ImageType.Rgb), 0}};

              Assert.AreEqual(count, images.Count);

              var display = new Display(image);
              images.Refresh();
              Assert.AreEqual(count + 1, images.Count);

              display.Delete();
              images.Refresh();

              /// Todo: the next assert fails! The number of images is still the same.
              Assert.AreEqual(count, images.Count);
              image.Delete();
        }
示例#13
0
        public void ConstructorFour()
        {
            var layer = new Layer(_image, "test", ImageType.Rgb);
              _image.InsertLayer(layer, 0);

              var image = new Image(_width, _height, ImageBaseType.Rgb);
              layer = new Layer(_image, image, "new_from_visible");
              image.InsertLayer(layer, 0);

              Assert.AreEqual(1, image.Layers.Count);
              Assert.AreEqual(image.Width, layer.Width);
              Assert.AreEqual(image.Height, layer.Height);
              Assert.AreEqual(100, layer.Opacity);
              Assert.AreEqual(LayerModeEffects.Normal, layer.Mode);

              image.Delete();
        }
示例#14
0
        public void CopyRgb2Rgba()
        {
            // Fill src region

              var pixel = new Pixel(13, 24, 35);
              FillDrawable(_drawable, pixel);

              // Copy to dest region
              var image = new Image(_width, _height, ImageBaseType.Rgb) {
            {new Layer("test", ImageType.Rgba), 0}};
              var drawable = image.ActiveDrawable;

              var srcRgn = new PixelRgn(_drawable, false, false);
              var destRgn = new PixelRgn(drawable, true, false);

              for (IntPtr pr = PixelRgn.Register(srcRgn, destRgn); pr != IntPtr.Zero;
               pr = PixelRgn.Process(pr))
            {
              for (int y = srcRgn.Y; y < srcRgn.Y + srcRgn.H; y++)
            {
              for (int x = srcRgn.X; x < srcRgn.X + srcRgn.W; x++)
            {
              var tmp = srcRgn[y, x];
              destRgn[y, x] = new Pixel(tmp.Red, tmp.Green, tmp.Blue, 255);
            }
            }
            }

              // Check results

              var pixel2 = new Pixel(13, 24, 35, 255);

              srcRgn = new PixelRgn(_drawable, false, false);
              destRgn = new PixelRgn(drawable, false, false);
              for (IntPtr pr = PixelRgn.Register(srcRgn, destRgn); pr != IntPtr.Zero;
               pr = PixelRgn.Process(pr))
            {
              for (int y = srcRgn.Y; y < srcRgn.Y + srcRgn.H; y++)
            {
              for (int x = srcRgn.X; x < srcRgn.X + srcRgn.W; x++)
            {
              Assert.AreEqual(pixel.Color, srcRgn[y, x].Color);
              Assert.AreEqual(pixel2.Color, destRgn[y, x].Color);
            }
            }
            }
              image.Delete();
        }
示例#15
0
        public void DirectAccessRgba()
        {
            var image = new Image(_width, _height, ImageBaseType.Rgb) {
            {new Layer("test", ImageType.Rgba), 0}};

              var drawable = image.ActiveDrawable;
              var pixel = new Pixel(13, 24, 35, 128);
              FillDrawable(drawable, pixel);

              var rgn = new PixelRgn(drawable, false, false);
              for (IntPtr pr = PixelRgn.Register(rgn); pr != IntPtr.Zero;
               pr = PixelRgn.Process(pr))
            {
              for (int y = rgn.Y; y < rgn.Y + rgn.H; y++)
            {
              for (int x = rgn.X; x < rgn.X + rgn.W; x++)
            {
              Assert.AreEqual(pixel.Color, rgn[y, x].Color);
            }
            }
            }
              image.Delete();
        }
示例#16
0
 public void NewIndexedImage()
 {
     var image = new Image(_width, _height, ImageBaseType.Indexed);
       Assert.AreEqual(ImageBaseType.Indexed, image.BaseType);
       image.Delete();
 }
示例#17
0
 public void NewGrayImage()
 {
     var image = new Image(_width, _height, ImageBaseType.Gray);
       Assert.AreEqual(ImageBaseType.Gray, image.BaseType);
       image.Delete();
 }
示例#18
0
 public void Exit()
 {
     _image.Delete();
 }
示例#19
0
 public void Duplicate()
 {
     var copy = new Image(_image);
       Assert.AreEqual(_image.Width, copy.Width);
       Assert.AreEqual(_image.Height, copy.Height);
       Assert.AreEqual(_image.BaseType, copy.BaseType);
       copy.Delete();
 }