private void DrawTag(QrCodeCustom qrCodeCustom, EncoderOptions options) { List <QrBitmapMatrix> matrixs = options.BitMats.FindAll(f => f.Tag == qrCodeCustom.QrCodeTag);// qrCodeCustom.QrCodeTag int ModuleSize = MudelSize / 7; int rowX = matrixs[0].Point.X * ModuleSize; int columnY = matrixs[0].Point.Y * ModuleSize; Bitmap bitmap = GetTagImg(options.LogoImgPath, qrCodeCustom.QrCodeTag); bitmap = OtsuThreshold(bitmap).ToBitmap(); //bitmap.Save(@"D:\Desktop\DIYcode\bitmap212313123123.jpg"); GraphicsCustom.DrawImage(bitmap, rowX, columnY, Rectangles[0].Width, Rectangles[0].Height); // throw new NotImplementedException(); }
public Bitmap DrawQrCode(EncoderOptions options) { Bitmap logoimg = GetLogoBitmap(options); Bitmap = new Bitmap(options.QrRect.QrCodeMinWidth, options.QrRect.QrCodeMinWidth, PixelFormat.Format24bppRgb); GraphicsCustom = Graphics.FromImage(Bitmap); GraphicsCustom.Clear(Color.White); if (options.IsTopLogoImg) { // Bitmap = new Bitmap(logoimg.Width, logoimg.Height, PixelFormat.Format24bppRgb); if (logoimg != null) { GraphicsCustom.DrawImage(logoimg, 0, 0, logoimg.Width, logoimg.Height); } } else { if (logoimg != null) { int pointx = (int)(Bitmap.Width / 2 - logoimg.Width / 2); int pointy = (int)(Bitmap.Height / 2 - logoimg.Height / 2); GraphicsCustom.DrawImage(logoimg, pointx, pointy, logoimg.Width, logoimg.Height); } } GraphicsCustom.Flush(); for (int i = 0; i < options.QrCodeCustoms.Count; i++) { QrCodeCustom qrCodeCustom = options.QrCodeCustoms[i]; if (qrCodeCustom.QrCodeTag != Tag.Content) { DrawTag(qrCodeCustom, options); } else { DrawingContent(qrCodeCustom, options); } } return(Bitmap); }