private void btn_Preview_Click(object sender, EventArgs e) { /* * Bitmap b = new Bitmap(picList[0]); * string b64 = "data:image/png;base64," + c_picconvert.pic2b64(b); * File.WriteAllText("C:\\REPO\\testhtml.html", "<img src='" + b64 + "' />"); */ c_PositionImages cp = new c_PositionImages(); List <string> smallpl = new List <string>(); for (int i = 0; i < psl[cb_Scheme.SelectedIndex].pics; i++) { try { smallpl.Add(picList[i]); } catch { } } Bitmap bmplst = cp.createPositions(psl[cb_Scheme.SelectedIndex], smallpl, a4sizes[8])[0]; pb_Scheme.SizeMode = PictureBoxSizeMode.StretchImage; pb_Scheme.Image = bmplst; //bmplst.Dispose(); GC.Collect(); }
private void btn_GenFiles_Click(object sender, EventArgs e) { c_PositionImages cp = new c_PositionImages(); List <Bitmap> bmplst = cp.createPositions(psl[cb_Scheme.SelectedIndex], picList, selectedDPI); FolderBrowserDialog fbd = new FolderBrowserDialog(); if (Properties.Settings.Default.s_LastDir != "" && Directory.Exists(Properties.Settings.Default.s_LastDir)) { fbd.SelectedPath = Properties.Settings.Default.s_LastDir; } fbd.ShowNewFolderButton = true; if (fbd.ShowDialog() == DialogResult.OK) { Properties.Settings.Default.s_LastDir = fbd.SelectedPath; Properties.Settings.Default.Save(); string path = fbd.SelectedPath; DateTime d = DateTime.Now; if (rb_PDF.Checked) { string fn = "pic_collage_pdf_" + d.Year + d.Month + d.Day + "_" + d.Hour + d.Minute + ".pdf"; using (PdfSharp.Pdf.PdfDocument pdoc = new PdfSharp.Pdf.PdfDocument()) { pdoc.PageLayout = PdfSharp.Pdf.PdfPageLayout.SinglePage; if (!Directory.Exists(fbd.SelectedPath)) { Directory.CreateDirectory(fbd.SelectedPath); } if (!Directory.Exists(fbd.SelectedPath + "\\tmp")) { Directory.CreateDirectory(fbd.SelectedPath + "\\tmp"); } foreach (Bitmap b in bmplst) { b.Save(fbd.SelectedPath + "\\tmp\\bmp_tmp_" + bmplst.IndexOf(b) + ".bmp"); PdfSharp.Pdf.PdfPage pag = pdoc.AddPage(); pag.Width = selectedDPI.width; pag.Height = selectedDPI.height; XGraphics gfx = XGraphics.FromPdfPage(pag); XImage image = XImage.FromFile(fbd.SelectedPath + "\\tmp\\bmp_tmp_" + bmplst.IndexOf(b) + ".bmp"); gfx.DrawImage(image, 0, 0, (int)pag.Width, (int)pag.Height); image.Dispose(); b.Dispose(); gfx.Dispose(); pag.Close(); } pdoc.Save(fbd.SelectedPath + "\\" + fn); } Directory.Delete(fbd.SelectedPath + "\\tmp", true); System.Diagnostics.Process.Start("explorer.exe", "/select, \"" + fbd.SelectedPath + "\\" + fn + "\""); } else { string fn = "bmp_" + d.Year + d.Month + d.Day + "_" + d.Hour + d.Minute + "_"; foreach (Bitmap b in bmplst) { b.Save(fbd.SelectedPath + "\\" + fn + bmplst.IndexOf(b) + ".bmp"); } System.Diagnostics.Process.Start("explorer.exe", "/select, \"" + fbd.SelectedPath + "\\" + fn + "0.bmp\""); } } GC.Collect(); }