コード例 #1
0
 /// <summary>
 /// Creates a black & white PNG of the QR code, using 1-bit grayscale.
 /// </summary>
 public byte[] GetGraphic(int pixelsPerModule)
 {
     using (var png = new PngBuilder())
     {
         var size = QrCodeData.ModuleMatrix.Count * pixelsPerModule;
         png.WriteHeader(size, size, 1, PngBuilder.ColorType.Greyscale);
         png.WriteScanlines(DrawScanlines(pixelsPerModule));
         png.WriteEnd();
         return(png.GetBytes());
     }
 }
コード例 #2
0
 /// <summary>
 /// Creates a black & white PNG of the QR code, using 1-bit grayscale.
 /// </summary>
 public byte[] GetGraphic(int pixelsPerModule, bool drawQuietZones = true)
 {
     using (var png = new PngBuilder())
     {
         var size = (this.QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : 8)) * pixelsPerModule;
         png.WriteHeader(size, size, 1, PngBuilder.ColorType.Greyscale);
         png.WriteScanlines(this.DrawScanlines(pixelsPerModule, drawQuietZones));
         png.WriteEnd();
         return(png.GetBytes());
     }
 }
コード例 #3
0
 /// <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());
     }
 }
コード例 #4
0
ファイル: QrCodePng.cs プロジェクト: depler/wgconfig
        public byte[] GetBytes()
        {
            using (var png = new PngBuilder())
            {
                var data = Draw();

                png.WriteHeader(scaledSize, scaledSize, 1, 0);
                png.WriteData(data);
                png.WriteEnd();

                return(png.GetBytes());
            }
        }