private void FillRectangle(Rgba32Color *bitmap, Rectangle2I rc, Rgba32Color color) { int bottom = rc.Bottom; int right = rc.Right; if (rc.Width >= rc.Height) { for (int iy = rc.Top; iy < bottom; iy++) { for (int ix = rc.Left; ix < right; ix++) { bitmap[ix + iy * renderArea.Width] = color; } } } else { for (int ix = rc.Left; ix < right; ix++) { for (int iy = rc.Top; iy < bottom; iy++) { bitmap[ix + iy * renderArea.Width] = color; } } } }
public void HighlightItems(WriteableBitmap bitmap, Rectangle2I rc, Rgba32Color color, IEnumerable <ITreemapItem> items) { if (rc.Width <= 0 || rc.Height <= 0) { return; } renderArea = rc; InitPixels(rc, Rgba32Color.Transparent); fixed(Rgba32Color *pBitmapBits = pixels) { foreach (FileItemBase item in items) { HighlightRectangle(pBitmapBits, item.Rectangle, color); } IntPtr bitmapBitsPtr = (IntPtr)pBitmapBits; ui.Invoke(() => { bitmap.WritePixels((Int32Rect)rc, bitmapBitsPtr, rc.Width * rc.Height * 4, bitmap.BackBufferStride); }); } }
private void HighlightRectangle(Rgba32Color *bitmap, Rectangle2I rc, Rgba32Color color) { if (rc.Width >= 7 && rc.Height >= 7) { FillRectangle(bitmap, Rectangle2I.FromLTRB(rc.Left, rc.Top, rc.Right, rc.Top + 3), color); FillRectangle(bitmap, Rectangle2I.FromLTRB(rc.Left, rc.Bottom - 3, rc.Right, rc.Bottom), color); FillRectangle(bitmap, Rectangle2I.FromLTRB(rc.Left, rc.Top + 3, rc.Left + 3, rc.Bottom - 3), color); FillRectangle(bitmap, Rectangle2I.FromLTRB(rc.Right - 3, rc.Top + 3, rc.Right, rc.Bottom - 3), color); } else if (rc.Width == 1 && rc.Height == 1) { bitmap[rc.Left + rc.Top * renderArea.Width] = color; } else if (rc.Width > 0 && rc.Height > 0) { FillRectangle(bitmap, rc, color); } }
public static Rgba32Color SetBrightness(Rgba32Color color, float brightness) { Debug.Assert(brightness >= 0); Debug.Assert(brightness <= 1); Number redf = color.R / 255f; Number greenf = color.G / 255f; Number bluef = color.B / 255f; Number f = 3 * brightness / (redf + greenf + bluef); int red = (int)(redf * f * 255); int green = (int)(greenf * f * 255); int blue = (int)(bluef * f * 255); NormalizeColor(ref red, ref green, ref blue); return(new Rgba32Color(red, green, blue, color.A)); }
public void HighlightItems(IWriteableBitmap bitmap, Rectangle2I rc, Rgba32Color color, IEnumerable <ITreemapItem> items) { if (rc.Width <= 0 || rc.Height <= 0) { return; } renderArea = rc; InitPixels(rc, Rgba32Color.Transparent); fixed(Rgba32Color *pBitmapBits = pixels) { foreach (FileItemBase item in items) { HighlightRectangle(pBitmapBits, item.Rectangle, color); } bitmap.SetPixels(pBitmapBits); } }
public static Rgba32Color SetBrightness(Rgba32Color color, float brightness) { Debug.Assert(brightness >= 0f); Debug.Assert(brightness <= 1f); float redf = color.R / 255f; float greenf = color.G / 255f; float bluef = color.B / 255f; float f = 3f * brightness / (redf + greenf + bluef); redf *= f; greenf *= f; bluef *= f; int red = (int) (redf * 255); int green = (int) (greenf * 255); int blue = (int) (bluef * 255); NormalizeColor(ref red, ref green, ref blue); return new Rgba32Color(red, green, blue); }
private void RecurseHighlightExtensions(Rgba32Color *bitmap, FileItemBase parent, Rgba32Color color, string extension) { List <FileItemBase> children = parent.Children; int count = children.Count; for (int i = 0; i < count; i++) { FileItemBase child = children[i]; Rectangle2S rc = child.Rectangle; if (rc.Width > 0 && rc.Height > 0) { if (child.IsLeaf) { if (child.Extension == extension) { HighlightRectangle(bitmap, rc, color); } } else { RecurseHighlightExtensions(bitmap, child, color, extension); } } } }
public void HighlightExtensions(WriteableBitmap bitmap, Rectangle2I rc, FileItemBase root, Rgba32Color color, string extension) { if (rc.Width <= 0 || rc.Height <= 0) { return; } renderArea = rc; InitPixels(rc, Rgba32Color.Transparent); fixed(Rgba32Color *pBitmapBits = pixels) { RecurseHighlightExtensions(pBitmapBits, root, color, extension); IntPtr bitmapBitsPtr = (IntPtr)pBitmapBits; ui.Invoke(() => { bitmap.WritePixels((Int32Rect)rc, bitmapBitsPtr, rc.Width * rc.Height * 4, bitmap.BackBufferStride); }); } }
public void HighlightExtensions(IWriteableBitmap bitmap, Rectangle2I rc, FileItemBase root, Rgba32Color color, string extension) { if (rc.Width <= 0 || rc.Height <= 0) { return; } renderArea = rc; InitPixels(rc, Rgba32Color.Transparent); fixed(Rgba32Color *pBitmapBits = pixels) { RecurseHighlightExtensions(pBitmapBits, root, color, extension); bitmap.SetPixels(pBitmapBits); } }
/// <summary>Casts the <see cref="Rgba32Color"/> to a <see cref="WpfColor"/>.</summary> public static WpfColor ToWpfColor(this Rgba32Color color) { return(WpfColor.FromArgb(color.A, color.R, color.G, color.B)); }
public static Number GetBrightness(Rgba32Color color) { return((color.R + color.G + color.B) / (Number)255 / 3); }
public static float GetBrightness(Rgba32Color color) { return (color.R + color.G + color.B) / 255f / 3f; }