private void button2_Click(object sender, EventArgs e) { if (lbl_logo.Text == "" || lbl_yoda.Text == "" || lbl_bottle.Text == "" || lbl_hand.Text == "" || lbl_point.Text == "" || lbl_result_folder.Text == "") { MessageBox.Show("You need select file or folder result"); return; } PointObjects pos = JsonConvert.DeserializeObject <PointObjects>(File.ReadAllText(lbl_point.Text)); string logo_result_path = render_logo(lbl_result_folder.Text, lbl_logo.Text, lbl_yoda.Text, lbl_bottle.Text, lbl_hand.Text, pos); lbl_result.Text = logo_result_path; if (MessageBox.Show("Bạn muốn mở file không ?", "Check", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { var p = new Process(); p.StartInfo = new ProcessStartInfo(logo_result_path) { UseShellExecute = true }; p.Start(); } }
private string render_logo(string folder_result, string logo_p, string yoda_p, string bottle_p, string hand_p, PointObjects pos) { string file_result_path = folder_result + "\\" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + "_logo.png"; using (MagickImage backgroud = new MagickImage(logo_p)) { MagickImage yoda = new MagickImage(yoda_p); MagickImage bottle = new MagickImage(bottle_p); MagickImage hand = new MagickImage(hand_p); //backgroud.Composite(yoda, 0, 1153, CompositeOperator.Over); //backgroud.Composite(bottle, 900, 2000, CompositeOperator.Over); //backgroud.Composite(hand, 700, 2320, CompositeOperator.Over); backgroud.Composite(yoda, pos.yoda[0], pos.yoda[1], CompositeOperator.Over); backgroud.Composite(bottle, pos.chai[0], pos.chai[1], CompositeOperator.Over); backgroud.Composite(hand, pos.tay[0], pos.tay[1], CompositeOperator.Over); backgroud.Write(file_result_path); } return(file_result_path); }