// Scanner selected? var device = Devices.SelectedItem as Scanner; if (device == null) { MessageBox.Show("Please select a device.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // Scan var images = device.Scan(); //Save the image strFinalImagename = txtPolicyno.Text + "_" + ddlDept.SelectedItem + "." + ddlFormat.SelectedItem; string strImagename = "test.jpg"; string path = System.Configuration.ConfigurationSettings.AppSettings["Path"] + strImagename; if (File.Exists(path)) { File.Delete(path); } System.IO.Directory.CreateDirectory(System.Configuration.ConfigurationSettings.AppSettings["Path"]); images.SaveFile(path); string ImageText = txtPolicyno.Text + "_" + ddlDept.SelectedItem; //System.Drawing.Bitmap bitMapImage = new System.Drawing.Bitmap(path); //System.Drawing.Graphics graphicImage = System.Drawing.Graphics.FromImage(bitMapImage); //graphicImage.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; //graphicImage.DrawArc(new System.Drawing.Pen(System.Drawing.Color.White, 3), 90, 235, 150, 50, 0, 360); //graphicImage.DrawString(ImageText, new System.Drawing.Font("Arial", 15, System.Drawing.FontStyle.Regular), System.Drawing.SystemBrushes.WindowText, new System.Drawing.Point(550, 20)); ////bitMapImage.Save(@"D:\" + strFinalImagename, System.Drawing.Imaging.ImageFormat.Jpeg); //bitMapImage.Save(System.Configuration.ConfigurationSettings.AppSettings["Path"] + strFinalImagename, System.Drawing.Imaging.ImageFormat.Jpeg); //graphicImage.Dispose(); //bitMapImage.Dispose(); using (var src = new System.Drawing.Bitmap(path)) using (var bmp = new System.Drawing.Bitmap(1000, 1000, System.Drawing.Imaging.PixelFormat.Format32bppPArgb)) using (var gr = System.Drawing.Graphics.FromImage(bmp)) { gr.Clear(System.Drawing.Color.Blue); gr.DrawImage(src, new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height)); gr.DrawString(ImageText, new System.Drawing.Font("Arial", 15, System.Drawing.FontStyle.Regular), System.Drawing.SystemBrushes.WindowText, new System.Drawing.Point(550, 20)); bmp.Save(System.Configuration.ConfigurationSettings.AppSettings["Path"] + strFinalImagename, System.Drawing.Imaging.ImageFormat.Png); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)