Exemplo n.º 1
0
        public void ActiveLayer()
        {
            var layer = new Layer(_image, "test", ImageType.Rgb);
              _image.InsertLayer(layer, 0);

              var active = _image.ActiveLayer;
              Assert.AreEqual(layer.Name, active.Name);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Create a GSImage backed with a new %Gimp# Image.
 /// </summary>
 /// <param name="width"></param>
 /// <param name="height"></param>
 public GSImage(int width, int height)
 {
     _image = new Gimp.Image(width, height, ImageBaseType.Gray);
     Layer layer = new Layer(_image, "default", width, height,
         ImageType.Gray, 100, LayerModeEffects.Normal);
     _image.AddLayer(layer, 0);
     _drawable = _image.ActiveDrawable;
     _rectangle = _drawable.MaskBounds;
     Tile.CacheDefault(_drawable);
     Progress = new Progress("Halftone Laboratory");
 }
Exemplo n.º 3
0
        public void AddAlpha()
        {
            var layer = new Layer(_image, "test", ImageType.Rgb);
              _image.InsertLayer(layer, 0);

              int bpp = layer.Bpp;
              Assert.AreEqual(3, bpp);

              layer.AddAlpha();
              Assert.AreEqual(ImageType.Rgba, layer.Type);
              Assert.AreEqual(bpp + 1, layer.Bpp);
        }
Exemplo n.º 4
0
        public void GetChildren()
        {
            var group = new LayerGroup(_image);
              Assert.AreEqual(0, group.Children.Count);
              _image.InsertLayer(group, null, 0);

              var layer = new Layer(_image, "test1", ImageType.Rgb);
              _image.InsertLayer(layer, group, 0);
              Assert.AreEqual(1, group.Children.Count);

              Assert.IsTrue(group.Children[0] is Layer);
        }
Exemplo n.º 5
0
        public void AddTwoDifferentLayerTypes()
        {
            var layer = new Layer(_image, "test1", ImageType.Rgb);
              _image.InsertLayer(layer, null, 0);

              var fontSize = new FontSize(32, Unit.Pixel);
              var textLayer = new TextLayer(_image, "Hello World", "Sans", fontSize);
              _image.InsertLayer(textLayer, null, 0);

              Assert.AreEqual(2, _image.Layers.Count);
              Assert.IsTrue(_image.Layers[0] is TextLayer);
              Assert.IsTrue(_image.Layers[1] is Layer);
        }
Exemplo n.º 6
0
        public void ApplyMask()
        {
            var layer = new Layer(_image, "test", ImageType.Rgba);
              layer.AddAlpha();
              _image.InsertLayer(layer, 0);

              layer.Mask = layer.CreateMask(AddMaskType.White);
              layer.ApplyMask = true;
              Assert.IsTrue(layer.ApplyMask);

              layer.ApplyMask = false;
              Assert.IsFalse(layer.ApplyMask);
        }
Exemplo n.º 7
0
        public void CreateMask()
        {
            var layer = new Layer(_image, "test", ImageType.Rgba);
              layer.AddAlpha();
              _image.InsertLayer(layer, 0);

              var mask = layer.CreateMask(AddMaskType.White);
              Assert.IsTrue(mask is Channel);
              Assert.AreEqual(true, mask.IsLayerMask);
              Assert.AreEqual(true, mask.IsChannel);

              layer.Mask = mask;
              Assert.AreEqual(layer, mask.Layer);
        }
Exemplo n.º 8
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();
        }
Exemplo n.º 9
0
        public void PickCorrelateLayer()
        {
            var layer = new Layer(_image, "test", ImageType.Rgb);
              var c = new Coordinate<int>(_width / 2, _height / 2);
              Assert.IsNull(_image.PickCorrelateLayer(c));

              _image.InsertLayer(layer, 0);

              var picked = _image.PickCorrelateLayer(c);
              Assert.AreEqual(layer, picked);
        }
Exemplo n.º 10
0
 public void Init()
 {
     _image = new Image(_width, _height, ImageBaseType.Rgb);
       var layer = new Layer(_image, "test", ImageType.Rgb);
       _image.InsertLayer(layer, 0);
 }
Exemplo n.º 11
0
        protected Image NewImage(int width, int height, ImageBaseType baseType,
            ImageType type, string filename)
        {
            var image = new Image(width, height, baseType) {Filename = filename};
              var layer = new Layer(image, "Background", type);
              image.InsertLayer(layer, 0);

              return image;
        }
Exemplo n.º 12
0
        public void Flatten()
        {
            var layer1 = new Layer(_image, "test1", ImageType.Rgb);
              _image.InsertLayer(layer1, 0);
              var layer2 = new Layer(_image, "test2", ImageType.Rgb);
              _image.InsertLayer(layer2, 0);

              Assert.AreEqual(2, _image.Layers.Count);
              _image.Flatten();
              Assert.AreEqual(1, _image.Layers.Count);
        }
Exemplo n.º 13
0
        public void ConvertIndexed()
        {
            var layer = new Layer(_image, "test", ImageType.Rgb);
              _image.InsertLayer(layer, 0);

              _image.ConvertIndexed(ConvertDitherType.No, ConvertPaletteType.Web,
                0, false, false, "");
              // Fixe me: next assert fails!
              Assert.IsTrue(_image.BaseType == ImageBaseType.Indexed);
        }
Exemplo n.º 14
0
 public void LowerLayerToBottom(Layer layer)
 {
     if (!gimp_image_lower_layer_to_bottom(ID, layer.ID))
     {
       throw new GimpSharpException();
     }
 }
Exemplo n.º 15
0
 public void RaiseLayerToTop(Layer layer)
 {
     if (!gimp_image_raise_layer_to_top(ID, layer.ID))
     {
       throw new GimpSharpException();
     }
 }
Exemplo n.º 16
0
 public void AddLayer(Layer layer, int position)
 {
     if (!gimp_image_add_layer(ID, layer.ID, position))
     {
       throw new GimpSharpException();
     }
 }
Exemplo n.º 17
0
        public void GetLayerPosition()
        {
            var layer1 = new Layer(_image, "test1", ImageType.Rgb);
              _image.InsertLayer(layer1, 0);
              var layer2 = new Layer(_image, "test2", ImageType.Rgb);
              _image.InsertLayer(layer2, 0);

              Assert.AreEqual(1, _image.GetItemPosition(layer1));
              Assert.AreEqual(0, _image.GetItemPosition(layer2));
        }
Exemplo n.º 18
0
        public void MergeVisibleLayers()
        {
            var layer1 = new Layer(_image, "test1", ImageType.Rgb);
              _image.InsertLayer(layer1, 0);
              var layer2 = new Layer(_image, "test2", ImageType.Rgb);
              _image.InsertLayer(layer2, 0);

              Assert.AreEqual(2, _image.Layers.Count);
              _image.MergeVisibleLayers(MergeType.ClipToImage);
              Assert.AreEqual(1, _image.Layers.Count);
        }
Exemplo n.º 19
0
        public void LowerLayerToBottom()
        {
            var layer1 = new Layer(_image, "test1", ImageType.Rgb);
              _image.InsertLayer(layer1, 0);
              var layer2 = new Layer(_image, "test2", ImageType.Rgb);
              _image.InsertLayer(layer2, 0);

              Assert.AreEqual(1, layer1.Position);
              Assert.AreEqual(0, layer2.Position);
              _image.LowerItemToBottom(layer2);
              Assert.AreEqual(0, layer1.Position);
              Assert.AreEqual(1, layer2.Position);
        }
Exemplo n.º 20
0
 public void GetThumbnail()
 {
     var layer = new Layer(_image, "test", ImageType.Rgb);
       _image.InsertLayer(layer, 0);
       var dimensions = new Dimensions(19, 23);
       var thumbnail = _image.GetThumbnail(dimensions, Transparency.KeepAlpha);
       int width = thumbnail.GetLength(1);
       int height = thumbnail.GetLength(0);
       Assert.AreEqual(dimensions, new Dimensions(width, height));
 }
Exemplo n.º 21
0
 public void Add(Layer layer, int position)
 {
     AddLayer(layer.DelayedConstruct(this), position);
 }
Exemplo n.º 22
0
        public void RaiseLayerToTop()
        {
            var layer1 = new Layer(_image, "test1", ImageType.Rgb);
              _image.InsertLayer(layer1, 0);
              var layer2 = new Layer(_image, "test2", ImageType.Rgb);
              _image.InsertLayer(layer2, 0);

              Assert.AreEqual(1, layer1.Position);
              Assert.AreEqual(0, layer2.Position);
              _image.RaiseItemToTop(layer1);
              Assert.AreEqual(0, layer1.Position);
              Assert.AreEqual(1, layer2.Position);
        }
Exemplo n.º 23
0
 public int GetLayerPosition(Layer layer)
 {
     return gimp_image_get_layer_position(ID, layer.ID);
 }
Exemplo n.º 24
0
 public void RemoveLayer()
 {
     var layer = new Layer(_image, "test", ImageType.Rgb);
       _image.InsertLayer(layer, 0);
       Assert.AreEqual(1, _image.Layers.Count);
       _image.RemoveLayer(layer);
       Assert.AreEqual(0, _image.Layers.Count);
 }
Exemplo n.º 25
0
 public Layer MergeDown(Layer layer, MergeType merge_type)
 {
     return new Layer(gimp_image_merge_down(ID, layer.ID, merge_type));
 }
Exemplo n.º 26
0
 public void ActiveDrawable()
 {
     var layer = new Layer(_image, "test", ImageType.Rgb);
       _image.InsertLayer(layer, 0);
       Assert.AreEqual(layer, _image.ActiveDrawable);
 }
Exemplo n.º 27
0
 public void RemoveLayer(Layer layer)
 {
     if (!gimp_image_remove_layer(ID, layer.ID))
     {
       throw new GimpSharpException();
     }
 }
Exemplo n.º 28
0
        public void ConvertGrayscale()
        {
            var layer = new Layer(_image, "test", ImageType.Rgb);
              _image.InsertLayer(layer, 0);

              var type = _image.BaseType;

              _image.ConvertGrayscale();
              Assert.IsTrue(_image.BaseType == ImageBaseType.Gray);

              // Fix me: find out why next assert fails!
              // Assert.Equals(ImageBaseType.Gray, _image.BaseType);
        }
Exemplo n.º 29
0
 public void LayerAlpha(Layer layer)
 {
     if (!gimp_selection_layer_alpha(layer.ID))
     {
       throw new GimpSharpException();
     }
 }
Exemplo n.º 30
0
        public void Parent()
        {
            var group = new LayerGroup(_image);
              _image.InsertLayer(group, null, 0);

              var layer = new Layer(_image, "test1", ImageType.Rgb);
              _image.InsertLayer(layer, group, 0);

              Assert.IsTrue(layer.Parent is LayerGroup);
              Assert.IsNull(layer.Parent.Parent);
        }