private void DrawBarcode(IGraphicsRenderer g, float width, float height) { SizeF originalSize = CalcBounds(); float kx = width / originalSize.Width; float ky = height / originalSize.Height; Draw2DBarcode(g, kx, ky); //If swiss qr, draw the swiss cross if (text.StartsWith("SPC")) { float top = showText ? height - 21 : height; g.FillRectangle(Brushes.White, width / 2 - width / 100f * 7, top / 2 - top / 100 * 7, width / 100f * 14, top / 100 * 14); g.FillRectangle(Brushes.Black, width / 2 - width / 100f * 6, top / 2 - top / 100 * 6, width / 100f * 12, top / 100 * 12); g.FillRectangle(Brushes.White, width / 2 - width / 100f * 4, top / 2 - top / 100 * 1.5f, width / 100f * 8, top / 100 * 3); g.FillRectangle(Brushes.White, width / 2 - width / 100f * 1.5f, top / 2 - top / 100 * 4, width / 100f * 3, top / 100 * 8); } // draw the text. if (showText) { string data = StripControlCodes(text); // When we print, .Net automatically scales the font. However, we need to handle this process. // Downscale the font to the screen resolution, then scale by required value (ky). float fontZoom = 18f / (int)g.MeasureString(data, FFont).Height *ky; using (Font drawFont = new Font(FFont.Name, FFont.Size * fontZoom, FFont.Style)) { g.DrawString(data, drawFont, Brushes.Black, new RectangleF(0, height - 18 * ky, width, 18 * ky)); } } }
internal override void Draw2DBarcode(IGraphicsRenderer g, float kx, float ky) { Brush light = Brushes.White; Brush dark = new SolidBrush(Color); GraphicsPath path = new GraphicsPath(); g.FillRectangle(light, 0, 0, matrix.Width * PixelSize * kx, matrix.Height * PixelSize * kx); for (int y = 0; y < matrix.Height; y++) { for (int x = 0; x < matrix.Width; x++) { if (matrix.get_Renamed(x, y) == 0) { path.AddRectangle(new RectangleF( x * PixelSize * kx, y * PixelSize * ky, PixelSize * kx, PixelSize * ky )); } } } if (path.PointCount > 0) { g.FillPath(dark, path); } }
internal override void Draw2DBarcode(IGraphicsRenderer g, float kx, float ky) { Brush light = Brushes.White; Brush dark = new SolidBrush(Color); for (int y = 0; y < matrix.Height; y++) { for (int x = 0; x < matrix.Width; x++) { bool b = matrix.getRow(y, null)[x]; Brush brush = b == true ? dark : light; g.FillRectangle(brush, x * PIXEL_SIZE * kx, y * PIXEL_SIZE * ky, PIXEL_SIZE * kx, PIXEL_SIZE * ky); } } }