private Bitmap generateImage(string type) { CollectionHandler ci = new CollectionHandler(); Information info = new Information(cmbVendorCode.Text, dtpDate.Value, cmbSerialNumber.Text, cmbShift.Text); Part part = ci.FindPart(cmbPart.Text); Drawer dr = new Drawer(); return(dr.GenerateTag(info, part)); }
private static Bitmap GenerateQRCode(string qrstring) { //GENERATE QR IMAGE CollectionHandler ci = new CollectionHandler(); DataMatrix.net.DmtxImageEncoder dIE = new DataMatrix.net.DmtxImageEncoder(); DataMatrix.net.DmtxImageEncoderOptions opts = new DataMatrix.net.DmtxImageEncoderOptions(); opts.Scheme = DataMatrix.net.DmtxScheme.DmtxSchemeAscii; opts.MarginSize = 0; opts.ModuleSize = 5; Bitmap finalQRImage = dIE.EncodeImage(qrstring, opts); return(finalQRImage); }
public Bitmap GenerateTag(Information info, Part part, string type) { EncodeHelper encoder = new EncodeHelper(info, part); //GENERATE MESSAGE IMAGE Bitmap finalMessageImage = new Bitmap(1, 1); int intWidth = 0; int intHeight = 0; Font objFont = null; //Printer 203dpi - Tag 2"x1" (406px x 203px) Point size = new Point(406, 203); Point qrsize = new Point(150, 150); if (type.Equals(Resources.GENERATEFORPREV)) { // Create the Font object for the image text drawing. objFont = new Font("Arial", 12, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); // This is where the bitmap size is determined. intWidth = 215; intHeight = 139; } else if (type.Equals(Resources.GENERATEFORSAVE)) { objFont = new Font("Arial", 8, FontStyle.Bold, GraphicsUnit.Pixel); // This is where the bitmap size is determined. intWidth = 75; intHeight = 75; } // Create a graphics object to measure the text's width and height. Graphics objGraphics = Graphics.FromImage(finalMessageImage); // Create the bmpImage again with the correct size for the text and font. finalMessageImage = new Bitmap(finalMessageImage, new Size(intWidth, intHeight)); // Add the colors to the new bitmap. objGraphics = Graphics.FromImage(finalMessageImage); // Set Background color objGraphics.Clear(Color.White); objGraphics.SmoothingMode = SmoothingMode.AntiAlias; objGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic; objGraphics.PixelOffsetMode = PixelOffsetMode.HighQuality; objGraphics.DrawString(encoder.messageString, objFont, new SolidBrush(Color.Black), 0, 0); objGraphics.Flush(); //GENERATE QR IMAGE CollectionHandler ci = new CollectionHandler(); DataMatrix.net.DmtxImageEncoder dIE = new DataMatrix.net.DmtxImageEncoder(); DataMatrix.net.DmtxImageEncoderOptions opts = new DataMatrix.net.DmtxImageEncoderOptions(); opts.Scheme = DataMatrix.net.DmtxScheme.DmtxSchemeAscii; Bitmap finalQRImage = dIE.EncodeImage(encoder.qRString, opts); if (type.Equals(Resources.GENERATEFORSAVE)) { finalQRImage = new Bitmap(finalQRImage, new Size(75, 75)); } return(CombineMessageAndQR(new Image[] { finalMessageImage, finalQRImage })); }