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(); }
public void NewIndexedImage() { var image = new Image(_width, _height, ImageBaseType.Indexed); Assert.AreEqual(ImageBaseType.Indexed, image.BaseType); image.Delete(); }
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(); }
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(); }
public void NewGrayImage() { var image = new Image(_width, _height, ImageBaseType.Gray); Assert.AreEqual(ImageBaseType.Gray, image.BaseType); image.Delete(); }
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(); }
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(); }
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(); }
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); }
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(); }
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); }
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(); }
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(); }
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(); }
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(); }
public void NewIndexedImage() { var image = new Image(_width, _height, ImageBaseType.Indexed); Assert.AreEqual(ImageBaseType.Indexed, image.BaseType); image.Delete(); }
public void NewGrayImage() { var image = new Image(_width, _height, ImageBaseType.Gray); Assert.AreEqual(ImageBaseType.Gray, image.BaseType); image.Delete(); }
public void Exit() { _image.Delete(); }
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(); }