public DirtyQuad(Rectangle rect) { BoundingRect = rect; if (false) // if (rect.Width > 128 && rect.Height > 128) { Nodes = new DirtyQuad[4]; int w0 = rect.Width / 2; int w1 = rect.Width - w0; int h0 = rect.Height / 2; int h1 = rect.Height - h0; int x = rect.X; int y = rect.Y; Rectangle childRect0 = new Rectangle(x, y, w0, h0); Nodes[0] = new DirtyQuad(childRect0); Rectangle childRect1 = new Rectangle(x + w0, y, w1, h0); Nodes[1] = new DirtyQuad(childRect1); Rectangle childRect2 = new Rectangle(x, y + h0, w0, h1); Nodes[2] = new DirtyQuad(childRect2); Rectangle childRect3 = new Rectangle(x + w0, y + h0, w1, h1); Nodes[3] = new DirtyQuad(childRect3); for (int i = 0; i < 4; i++) { Nodes[i].Index = i; Nodes[i].Parent = this; if (i < 3) { Nodes[i].Next = Nodes[i + 1]; } } HasChildren = true; } }
public WriteableBitmapChildRenderer(int width, int height) { _transparentBrush = new SWM.SolidColorBrush(SWM.Colors.Transparent); _width = width; _height = height; _clearArray = new int[_width]; _clearRect = new System.Windows.Shapes.Rectangle(); _clearRect.Width = _width; _clearRect.Height = _height; _img = new Image(); _bmp = new WriteableBitmap(_width, _height); _img.Source = _bmp; _img.Width = _width; _img.Height = _height; Root = _img; _text = new TextBlock(); _textTranslate = new SWM.TranslateTransform(); _quads = new DirtyQuad(new Rectangle(0, 0, width, height)); }
DirtyQuad GetNextNode(DirtyQuad current) { DirtyQuad next = current.Next; if (next != null) return next; if (current.Parent == null) return null; return GetNextNode(current.Parent); }