/// <summary> /// Creates 2-color PNG of the QR code, using 1-bit indexed color. Accepts 3-byte RGB colors for normal images and 4-byte RGBA-colors for transparent images. /// </summary> public byte[] GetGraphic(int pixelsPerModule, byte[] darkColorRgba, byte[] lightColorRgba) { using (var png = new PngBuilder()) { var size = this.m_xCodeData.ModuleMatrix.Count * pixelsPerModule; png.WriteHeader(size, size, 1, PngBuilder.ColorType.Indexed); png.WritePalette(darkColorRgba, lightColorRgba); png.WriteScanlines(this.DrawScanlines(pixelsPerModule)); png.WriteEnd(); return(png.GetBytes()); } }