private ColorBgra[] GetPixelsFromPoint(PointD point) { var doc = PintaCore.Workspace.ActiveDocument; var x = (int)point.X; var y = (int)point.Y; var size = SampleSize; var half = size / 2; // Short circuit for single pixel if (size == 1) { return new ColorBgra[] { GetPixel(x, y) } } ; // Find the pixels we need (clamp to the size of the image) var rect = new Gdk.Rectangle(x - half, y - half, size, size); rect.Intersect(new Gdk.Rectangle(Gdk.Point.Zero, doc.ImageSize)); var pixels = new List <ColorBgra> (); for (int i = rect.Left; i <= rect.GetRight(); i++) { for (int j = rect.Top; j <= rect.GetBottom(); j++) { pixels.Add(GetPixel(i, j)); } } return(pixels.ToArray()); }
public void SetSamplePoint(Gdk.Point p) { region.X = p.X; region.Y = p.Y; region.Width = 2 * radius; region.Height = 2 * radius; if (view.Pixbuf != null) { Gdk.Pixbuf pixbuf = view.Pixbuf; region.Offset(-Math.Min(region.X, Math.Max(region.Right - pixbuf.Width, radius)), -Math.Min(region.Y, Math.Max(region.Bottom - pixbuf.Height, radius))); region.Intersect(new Gdk.Rectangle(0, 0, pixbuf.Width, pixbuf.Height)); } UpdateSample(); }
private ColorBgra ComputeCellColor(int x, int y, ImageSurface src, int cellSize, Gdk.Rectangle srcBounds) { Gdk.Rectangle cell = GetCellBox(x, y, cellSize); cell.Intersect(srcBounds); int left = cell.Left; int right = cell.GetRight(); int bottom = cell.GetBottom(); int top = cell.Top; ColorBgra colorTopLeft = src.GetColorBgraUnchecked(left, top).ToStraightAlpha(); ColorBgra colorTopRight = src.GetColorBgraUnchecked(right, top).ToStraightAlpha(); ColorBgra colorBottomLeft = src.GetColorBgraUnchecked(left, bottom).ToStraightAlpha(); ColorBgra colorBottomRight = src.GetColorBgraUnchecked(right, bottom).ToStraightAlpha(); ColorBgra c = ColorBgra.BlendColors4W16IP(colorTopLeft, 16384, colorTopRight, 16384, colorBottomLeft, 16384, colorBottomRight, 16384); return(c.ToPremultipliedAlpha()); }
private ColorBgra ComputeCellColor(int x, int y, ImageSurface src, int cellSize, Gdk.Rectangle srcBounds) { Gdk.Rectangle cell = GetCellBox(x, y, cellSize); cell.Intersect(srcBounds); int left = cell.Left; int right = cell.Right - 1; int bottom = cell.Bottom - 1; int top = cell.Top; ColorBgra colorTopLeft = src.GetColorBgra(left, top); ColorBgra colorTopRight = src.GetColorBgra(right, top); ColorBgra colorBottomLeft = src.GetColorBgra(left, bottom); ColorBgra colorBottomRight = src.GetColorBgra(right, bottom); ColorBgra c = ColorBgra.BlendColors4W16IP(colorTopLeft, 16384, colorTopRight, 16384, colorBottomLeft, 16384, colorBottomRight, 16384); return(c); }
private ColorBgra[] GetPixelsFromPoint(PointD point) { var doc = PintaCore.Workspace.ActiveDocument; var x = (int)point.X; var y = (int)point.Y; var size = SampleSize; var half = size / 2; // Short circuit for single pixel if (size == 1) return new ColorBgra[] { GetPixel (x, y) }; // Find the pixels we need (clamp to the size of the image) var rect = new Gdk.Rectangle (x - half, y - half, size, size); rect.Intersect (new Gdk.Rectangle (Gdk.Point.Zero, doc.ImageSize)); var pixels = new List<ColorBgra> (); for (int i = rect.Left; i <= rect.GetRight (); i++) for (int j = rect.Top; j <= rect.GetBottom (); j++) pixels.Add (GetPixel (i, j)); return pixels.ToArray (); }
public void QueueDirtyRegion(Gdk.Rectangle region) { region.Intersect(Allocation); QueueDrawArea(region.X, region.Y, region.Width, region.Height); }