public void ForegroundColor() { var grid = _image.Grid; RGB color = new RGB(11, 22, 33); grid.ForegroundColor = color; Assert.AreEqual(color, grid.ForegroundColor); }
public void AddOperator() { double red = 0.13; double green = 0.24; double blue = 0.35; RGB rgb = new RGB(red, green, blue); RGB result = rgb + new RGB(0, 0, 0); Assert.AreEqual(rgb, result); }
public void Alpha() { double red = 0.13; double green = 0.24; double blue = 0.35; RGB rgb = new RGB(red, green, blue); rgb.Alpha = 0.5; Assert.AreEqual(0.5, rgb.Alpha); }
public void Add() { double red = 0.13; double green = 0.24; double blue = 0.35; RGB rgb = new RGB(red, green, blue); rgb.Add(new RGB(0, 0, 0)); Assert.AreEqual(new RGB(red, green, blue), rgb); }
public void Bytes() { byte red = 13; byte green = 24; byte blue = 35; RGB rgb = new RGB(red, green, blue); byte[] bytes = rgb.Bytes; Assert.AreEqual(new byte[]{red, green, blue}, bytes); }
public void Background() { RGB background = new RGB(11, 12, 13); Context.Background = background; RGB result = Context.Background; Assert.AreEqual(background.R, result.R); Assert.AreEqual(background.G, result.G); Assert.AreEqual(background.B, result.B); // Fix me: why doesn't Assert.AreEqual(background, result) just work? }
public void CombineMasks() { RGB color = new RGB(0, 255, 0); var channelOne = new Channel(_image, "one", color); var channelTwo = new Channel(_image, "two", color); _image.AddChannel(channelOne, 0); _image.AddChannel(channelTwo, 0); channelOne.CombineMasks(channelTwo, ChannelOps.Add, 0, 0); }
public void Select(RGB color, int threshold, ChannelOps operation, bool antialias, bool feather, double featherRadius, bool sampleMerged) { var rgb = color.GimpRGB; if (!gimp_by_color_select(_drawableID, ref rgb, threshold, operation, antialias, feather, featherRadius, sampleMerged)) { throw new GimpSharpException(); } }
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])); } } } }
public void Fill() { // Fill with some color RGB foreground = new RGB(22, 55, 77); Context.Push(); Context.Foreground = foreground; _drawable.Fill(FillType.Foreground); Context.Pop(); using (PixelFetcher pf = new PixelFetcher(_drawable, false)) { Pixel pixel = pf[_height / 2, _width / 2]; Assert.AreEqual(foreground, pixel.Color); } }
public void SegmentSetRightColor(int segment, RGB color, double opacity) { var rgb = color.GimpRGB; if (!gimp_gradient_segment_set_right_color(Name, segment, ref rgb, opacity)) { throw new GimpSharpException(); } }
public void SetUChar() { RGB rgb = new RGB(0, 0, 0); byte red = 13; byte green = 24; byte blue = 35; rgb.SetUchar(red, green, blue); byte r, g, b; rgb.GetUchar(out r, out g, out b); Assert.AreEqual(red, r); Assert.AreEqual(green, g); Assert.AreEqual(blue, b); }
public double Distance(RGB rgb) { return gimp_rgb_distance(ref _rgb, ref rgb._rgb); }
public static RGB Interpolate(double value, RGB rgb1, RGB rgb2) { double r = rgb1.R + value * (rgb2.R - rgb1.R); double g = rgb1.G + value * (rgb2.G - rgb1.G); double b = rgb1.B + value * (rgb2.B - rgb1.B); return new RGB(r, g, b); }
public static RGB operator +(RGB rgb1, RGB rgb2) { RGB result = new RGB(rgb1); result.Add(rgb2); return result; }
public PaletteEntry AddEntry(string entryName, RGB color) { GimpRGB rgb = color.GimpRGB; int entryNum; if (!gimp_palette_add_entry(Name, entryName, ref rgb, out entryNum)) { throw new GimpSharpException(); } return new PaletteEntry(this, entryNum); }
public void Foreground() { RGB foreground = new RGB(11, 12, 13); Context.Foreground = foreground; RGB result = Context.Foreground; Assert.AreEqual(foreground.R, result.R); Assert.AreEqual(foreground.G, result.G); Assert.AreEqual(foreground.B, result.B); // Fix me: why doesn't Assert.AreEqual(foreground, result) just work? // Answer: because of the undefined alpha channel }
public void ParseInvalidCss() { RGB rgb = new RGB(0, 0, 0); rgb.ParseCss("#nonsense"); }
public void ClampNothing() { double red = 0.13; double green = 0.24; double blue = 0.35; RGB rgb = new RGB(red, green, blue); rgb.Clamp(); Assert.AreEqual(new RGB(red, green, blue), rgb); }
public void ParseName() { RGB rgb = new RGB(0, 0, 0); rgb.ParseName("blue"); Assert.AreEqual(new RGB(0, 0, 255), rgb); }
public static RGB operator *(RGB rgb, double factor) { RGB result = new RGB(rgb); result.Multiply(factor); return result; }
public RGB(RGB rgb) : this(rgb.R, rgb.G, rgb.B) { }
public static RGB operator +(RGB rgb, double v) { RGB result = new RGB(rgb); result.R += v; result.G += v; result.B += v; return result; }
public void ParseInvalidHex() { RGB rgb = new RGB(0, 0, 0); rgb.ParseHex("#nonsense"); }
public static RGB operator -(RGB rgb1, RGB rgb2) { RGB result = new RGB(rgb1); result.Subtract(rgb2); return result; }
public Channel(Image image, string name, int width, int height, double opacity, RGB color) : this(image, name, width, height, opacity, color.GimpRGB) { }
public void Add(RGB rgb) { gimp_rgb_add(ref _rgb, ref rgb._rgb); }
public Channel(Image image, string name, RGB color) : this(image, name, image.Width, image.Height, 100, color.GimpRGB) { }
public void Subtract(RGB rgb) { gimp_rgb_subtract(ref _rgb, ref rgb._rgb); }
public void Subtract() { double red = 0.13; double green = 0.24; double blue = 0.35; RGB rgb = new RGB(red, green, blue); RGB tmp = new RGB(red, green, blue); rgb.Subtract(new RGB(0, 0, 0)); Assert.AreEqual(tmp, rgb); }
public GimpColorButton(string title, int width, int height, RGB color, ColorAreaType type) : this(title, width, height, color.GimpRGB, type) { }
public byte[] GetColorUchar(RGB color) { var colorUchar = new byte[_bpp]; var rgb = color.GimpRGB; gimp_drawable_get_color_uchar(ID, ref rgb, colorUchar); return colorUchar; }