Пример #1
0
 public void ConstructorOne()
 {
     var pixel = new Pixel(3);
       Assert.AreEqual(0, pixel.Red);
       Assert.AreEqual(0, pixel.Green);
       Assert.AreEqual(0, pixel.Blue);
 }
Пример #2
0
 public void CopyFrom()
 {
     var pixel = new Pixel(3);
       var src = new byte[]{11, 12, 13};
       pixel.CopyFrom(src, 0);
       Assert.AreEqual(src, pixel.Bytes);
 }
Пример #3
0
 public void ConstructorThree()
 {
     var pixel = new Pixel(11, 12, 13);
       Assert.AreEqual(11, pixel.Red);
       Assert.AreEqual(12, pixel.Green);
       Assert.AreEqual(13, pixel.Blue);
 }
Пример #4
0
 public void ConstructorFor()
 {
     var pixel = new Pixel(11, 12, 13, 255);
       Assert.AreEqual(11, pixel.Red);
       Assert.AreEqual(12, pixel.Green);
       Assert.AreEqual(13, pixel.Blue);
       Assert.AreEqual(255, pixel.Alpha);
 }
Пример #5
0
 public void ConstructorTwo()
 {
     var rgb = new byte[]{11, 12, 13};
       var pixel = new Pixel(rgb);
       Assert.AreEqual(11, pixel.Red);
       Assert.AreEqual(12, pixel.Green);
       Assert.AreEqual(13, pixel.Blue);
 }
Пример #6
0
 public void AddOne()
 {
     var pixel1 = new Pixel(11, 12, 13);
       var pixel2 = new Pixel(1, 1, 1);
       pixel1.Add(pixel2);
       Assert.AreEqual(12, pixel1.Red);
       Assert.AreEqual(13, pixel1.Green);
       Assert.AreEqual(14, pixel1.Blue);
 }
Пример #7
0
        public void TestFill()
        {
            var color = new Pixel(12, 13, 14);

              var iterator = new RgnIterator(_drawable, RunMode.Noninteractive);
              iterator.IterateDest((x, y) => {return color;});

              iterator.IterateSrc(pixel => pixel.IsSameColor(color));
        }
Пример #8
0
        public void PutGetPixel()
        {
            // Fill with some color
              var foreground = new RGB(22, 55, 77);
              Context.Push();
              Context.Foreground = foreground;
              _drawable.Fill(FillType.Foreground);
              Context.Pop();

              var expected = new Pixel(33, 66, 99);

              // Fill with different color, using shadow
              using (var pf = new PixelFetcher(_drawable, true))
            {
              for (int y = 0; y < _height; y++)
            {
              for (int x = 0; x < _width; x++)
            {
              pf[y, x] = expected;
            }
            }
            }

              // check that original hasn't changed
              using (var pf = new PixelFetcher(_drawable, false))
            {
              for (int y = 0; y < _height; y++)
            {
              for (int x = 0; x < _width; x++)
            {
              Assert.AreEqual(foreground, pf[y, x].Color);
            }
            }
            }

              _drawable.MergeShadow(true);

              // and now the orginal should be changed
              using (var pf = new PixelFetcher(_drawable, false))
            {
              for (int y = 0; y < _height; y++)
            {
              for (int x = 0; x < _width; x++)
            {
              Assert.IsTrue(expected.IsSameColor(pf[y, x]));
            }
            }
            }
        }
Пример #9
0
 public void SetBytes()
 {
     var rgb = new byte[]{11, 12, 13};
       var pixel = new Pixel(3) {Bytes = rgb};
       Assert.AreEqual(rgb, pixel.Bytes);
 }
Пример #10
0
        public void IsSameColor()
        {
            var pixel1 = new Pixel(11, 12, 13);
              var pixel2 = new Pixel(11, 12, 13);
              var pixel3 = new Pixel(21, 22, 23);

              Assert.IsTrue(pixel1.IsSameColor(pixel2));
              Assert.IsFalse(pixel1.IsSameColor(pixel3));
        }
Пример #11
0
 public void GetSetRed()
 {
     var pixel = new Pixel(3) {Red = 127};
       Assert.AreEqual(127, pixel.Red);
 }
Пример #12
0
 public void GetSetGreen()
 {
     var pixel = new Pixel(3) {Green = 127};
       Assert.AreEqual(127, pixel.Green);
 }
Пример #13
0
 public void GetSetBlue()
 {
     var pixel = new Pixel(3) {Blue = 127};
       Assert.AreEqual(127, pixel.Blue);
 }
Пример #14
0
 public void FillTwo()
 {
     var pixel = new Pixel(11, 12, 13);
       pixel.Fill(x => {return x + 1;});
       Assert.AreEqual(12, pixel.Red);
       Assert.AreEqual(13, pixel.Green);
       Assert.AreEqual(14, pixel.Blue);
 }
Пример #15
0
 public void FillOne()
 {
     var pixel = new Pixel(3);
       pixel.Fill(() => {return 11;});
       Assert.AreEqual(11, pixel.Red);
       Assert.AreEqual(11, pixel.Green);
       Assert.AreEqual(11, pixel.Blue);
 }
Пример #16
0
 public void PutPixel(int x, int y, Pixel pixel)
 {
     gimp_pixel_fetcher_put_pixel(_ptr, x, y, pixel.Bytes);
 }
Пример #17
0
 public void GetSetXY()
 {
     var pixel = new Pixel(11, 12, 13) {X = 123, Y = 321};
       Assert.AreEqual(123, pixel.X);
       Assert.AreEqual(321, pixel.Y);
 }
Пример #18
0
        public void HasAlpha()
        {
            var pixel = new Pixel(1);
              Assert.IsFalse(pixel.HasAlpha);

              pixel = new Pixel(2);
              Assert.IsTrue(pixel.HasAlpha);

              pixel = new Pixel(3);
              Assert.IsFalse(pixel.HasAlpha);

              pixel = new Pixel(4);
              Assert.IsTrue(pixel.HasAlpha);
        }
Пример #19
0
 public void CopyTo()
 {
     var rgb = new byte[]{11, 12, 13};
       var pixel = new Pixel(3) {Bytes = rgb};
       var dest = new byte[3];
       pixel.CopyTo(dest, 0);
       Assert.AreEqual(dest, pixel.Bytes);
 }
Пример #20
0
        public void This()
        {
            using (var pf = new PixelFetcher(_drawable, false))
            {
              var expected = new Pixel(33, 66, 99);

              for (int y = 0; y < _height; y++)
            {
              for (int x = 0; x < _width; x++)
            {
              pf[y, x] = expected;
              Assert.IsTrue(expected.IsSameColor(pf[y, x]));
            }
            }
            }
        }