private void WriteOffset(int offsetX, int offsetY, UnsafeMemoryBuffer ms) { ms.Write(offset, 7); var xNum = numbers[offsetX]; ms.WriteNullTerminated(xNum); ms.WriteByte(space); var yNum = numbers[offsetY]; ms.WriteNullTerminated(yNum); ms.WriteByte(newline); }
private void RenderPixels(OutputPixel[] pixels, int offsetX, int offsetY, bool omitOffset, bool greyscaleSupported, UnsafeMemoryBuffer ms) { var canvasWidth = _canvasSize.Width; var canvasHeight = _canvasSize.Height; var len = pixels.Length; for (int i = 0; i < len; i++) { var pixel = pixels[i]; var argbColor = pixel.Color; var a = (byte)(argbColor >> 24 & 0xFF); if (a == 0) { continue; } int pixelX; int pixelY; if (omitOffset) { pixelX = pixel.X; pixelY = pixel.Y; } else { pixelX = pixel.X + offsetX; pixelY = pixel.Y + offsetY; } if (pixelX >= canvasWidth || pixelY >= canvasHeight) { continue; } ms.Write(px, 3); var xNum = numbers[pixelX]; ms.WriteNullTerminated(xNum); ms.WriteByte(space); var yNum = numbers[pixelY]; ms.WriteNullTerminated(yNum); ms.WriteByte(space); if (greyscaleSupported && IsGreyScale(argbColor, out var grey) && a == 0xFF) { ms.Write(hexNumbers + (grey << 1), 2); } else { ms.Write(hexColors + (argbColor & 0x00FFFFFF) * 6, 6); if (a != 0xFF) { ms.Write(hexNumbers + (a << 1), 2); } } ms.WriteByte(newline); } }