private void BT_Open_Click(object sender, EventArgs e) { //try { String path1 = TB_ConfigPath.Text; String path2 = TB_TexturePath.Text; if (path1 == "" || path2 == "") { return; } if (RB_Plist.Checked == true) //Plist { plistLoad = new PlistLoad(path1); Image img = Image.FromFile(path2); Bitmap bmp = new Bitmap(img); if (CB_ShowFrame.Checked == true) { Graphics g = Graphics.FromImage(bmp); Pen pen = new Pen(Color.Red, 1); foreach (PlistFrame frame in plistLoad.plistFile.frames) { if (frame.rotated == true) { g.DrawRectangle(pen, new Rectangle(frame.frame.Left, frame.frame.Top, frame.frame.Height, frame.frame.Width)); } else { g.DrawRectangle(pen, frame.frame); } } } texture_box.Image = bmp; } else if (RB_Atlas.Checked == true) //Atlas { atlasLoad = new Atlas(path1); Image img = Image.FromFile(path2); Bitmap bmp = new Bitmap(img); if (CB_ShowFrame.Checked == true) { Graphics g = Graphics.FromImage(bmp); Pen pen = new Pen(Color.Red, 1); foreach (AtlasRegion region in atlasLoad.List_atlasFile[0].region) { if (region.rotate == true) { g.DrawRectangle(pen, new Rectangle(region.xy, new Size(region.size.Height, region.size.Width))); } else { g.DrawRectangle(pen, new Rectangle(region.xy, region.size)); } } } texture_box.Image = bmp; } } //catch //{ // MessageBox.Show("路径或格式错误"); //} }
private bool OpenImage() { try { String path1 = textBox1.Text; String path2 = textBox2.Text; if (path1 == "" || path2 == "") { return(false); } //Plist if (r1.Checked == true) { plistLoad = new PlistLoad(path1); //Image img = Image.FromFile(path2); //Bitmap bmp = new Bitmap(img); Bitmap source = ImageLoad.FileToBitmap(path2); if (checkBox1.Checked == true) { Graphics g = Graphics.FromImage(source); Pen pen = new Pen(Color.Red, 1); foreach (PlistFrame frame in plistLoad.plistFile.frames) { if (frame.rotated == true) { g.DrawRectangle(pen, new Rectangle( frame.frame.Left, frame.frame.Top, frame.frame.Height, frame.frame.Width)); } else { g.DrawRectangle(pen, frame.frame); } } } pictureBox1.Image = source; } //Atlas else if (r2.Checked == true) { atlasLoad = new AtlasLoad(path1); Bitmap bmp = ImageLoad.FileToBitmap(path2); if (checkBox1.Checked == true) { Graphics g = Graphics.FromImage(bmp); Pen pen = new Pen(Color.Red, 1); foreach (AtlasRegion region in atlasLoad.List_atlasFile[0].region) { if (region.rotate == true) { g.DrawRectangle(pen, new Rectangle(region.xy, new Size(region.size.Height, region.size.Width))); } else { g.DrawRectangle(pen, new Rectangle(region.xy, region.size)); } } } pictureBox1.Image = bmp; } } catch (Exception e) { MessageBox.Show(e.Message, "无法打开图片", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); }
private void button3_Click(object sender, EventArgs e) { //try { String path1 = textBox1.Text; String path2 = textBox2.Text; if (path1 == "" || path2 == "") { return; } //Plist if (r1.Checked == true) { plistLoad = new PlistLoad(path1); Image img = Image.FromFile(path2); Bitmap bmp = new Bitmap(img); if (checkBox1.Checked == true) { Graphics g = Graphics.FromImage(bmp); Pen pen = new Pen(Color.Red, 1); foreach (PlistFrame frame in plistLoad.plistFile.frames) { if (frame.rotated == true) { g.DrawRectangle(pen, new Rectangle( frame.frame.Left, frame.frame.Top, frame.frame.Height, frame.frame.Width)); } else { g.DrawRectangle(pen, frame.frame); } } } pictureBox1.Image = bmp; } //Atlas else if (r2.Checked == true) { atlasLoad = new AtlasLoad(path1); Image img = Image.FromFile(path2); Bitmap bmp = new Bitmap(img); if (checkBox1.Checked == true) { Graphics g = Graphics.FromImage(bmp); Pen pen = new Pen(Color.Red, 1); foreach (AtlasRegion region in atlasLoad.List_atlasFile[0].region) { if (region.rotate == true) { g.DrawRectangle(pen, new Rectangle(region.xy, new Size(region.size.Height, region.size.Width))); } else { g.DrawRectangle(pen, new Rectangle(region.xy, region.size)); } } } pictureBox1.Image = bmp; } } //catch //{ // MessageBox.Show("路径或格式错误"); //} }