void ILcdBoostElement.Render( LcdBoostVideoCache cache, LcdBoostRect container ) { //gets the global cache point where the character //has to be written int xd = System.Math.Max(0, this.X) + container.Left; int yd = System.Math.Max(0, this.Y) + container.Top; /** * hard-copy the local cache onto the global **/ var face = (int)this.Face; if (face != LcdBoostElementTextArea.Transparent) { //it assumes that the whole area is opaque //thus the copy is much simpler (and faster) if (container.Contains(xd, yd)) { cache.Data[yd][xd] = (byte)face; } } }
public LcdBoostRect Intersect(LcdBoostRect other) { var result = new LcdBoostRect(); result._left = System.Math.Max( other._left, this._left); result._top = System.Math.Max( other._top, this._top); result._width = System.Math.Min(other.Right, this.Right) - result.Left + 1; result._height = System.Math.Min(other.Bottom, this.Bottom) - result.Top + 1; return(result); }
void ILcdBoostElement.Render( LcdBoostVideoCache cache, LcdBoostRect container ) { //rebuild the local cache when something has been changed if (this._changed || this.Bounds.WidthHeightChanged) { this.Recalc(); } /** * calculate actual rect bounds to be used **/ //gets the upper-left point from where the //data of the local cache have to be read from int xs = System.Math.Max(0, -this.Bounds.Left); int ys = System.Math.Max(0, -this.Bounds.Top); //gets the upper-left point from where the //data of the global cache have to be written to int xd = System.Math.Max(0, this.Bounds.Left) + container.Left; int yd = System.Math.Max(0, this.Bounds.Top) + container.Top; //gets the actual box size to be considered int w = System.Math.Min(container.Right, container.Left + this.Bounds.Right) - xd + 1; int h = System.Math.Min(container.Bottom, container.Top + this.Bounds.Bottom) - yd + 1; /** * hard-copy the local cache onto the global **/ if (this._background == Transparent) { //must take in account every single byte //to check whether is transparent for (int iy = 0; iy < h; iy++) { byte[] src_row = this._cache[iy + ys]; byte[] dest_row = cache.Data[iy + yd]; for (int ix = 0; ix < w; ix++) { byte code = src_row[ix + xs]; if (code != Transparent) { dest_row[ix + xd] = code; } } } } else { //it assumes that the whole area is opaque //thus the copy is much simpler (and faster) for (int iy = 0; iy < h; iy++) { byte[] src_row = this._cache[iy + ys]; byte[] dest_row = cache.Data[iy + yd]; Array.Copy( src_row, xs, dest_row, xd, w); } } }