private void openFileDialog_Click(object sender, EventArgs e) { if (constant) { return; } openFileDialog1.Filter = "PNG (*.png)|*.png|All files (*.*)|*.*"; DialogResult res = openFileDialog1.ShowDialog(); if (res == DialogResult.Cancel) { return; } if (openFileDialog1.SafeFileName == "") { return; } if (openFileDialog1.SafeFileName.Split('.')[1] != "png") { MessageBox.Show("Нужно выбрать *.png файл"); return; } imageName = openFileDialog1.SafeFileName; ApplyImage(openFileDialog1.FileName); FillPropPanel(parentTabPage.GetPropertiesPanel()); pictureBox1.Image = ImageBlend.MergeWithPanel(parentTabPage.GetDesktopPanel(), new Bitmap(pictureBox1.Image), new Point(Location.X + parentTabPage.GetDesktopPanel().AutoScrollPosition.X, Location.Y + parentTabPage.GetDesktopPanel().AutoScrollPosition.Y)); }
public override void ColorImagesToPanelColor() { pictureBox1.Image = ImageBlend.MergeWithPanel(parentTabPage.GetDesktopPanel(), new Bitmap(activeImage), new Point(Location.X + parentTabPage.GetDesktopPanel().AutoScrollPosition.X, Location.Y + parentTabPage.GetDesktopPanel().AutoScrollPosition.Y)); if (overlayEnabled) { pictureBox2.Image = new Bitmap(overlayImage); ImageBlend.Blend(pictureBox1.Image, pictureBox2.Image); } }
private void CombineDrawingsWithElements() { //save foreach (Control c in parentTabPage.GetDesktopPanel().Controls) { if (c.GetType() == typeof(Label) || c.GetType() == typeof(InnerHeader)) { continue; } if (c.GetType() == typeof(InnerBitmap)) { InnerBitmap innerBitmap = (InnerBitmap)c; ((PictureBox)innerBitmap.Controls[0]).Image = ImageBlend.MergeWithPanel(parentTabPage.GetDesktopPanel(), new Bitmap(((PictureBox)innerBitmap.Controls[0]).Image), new Point(c.Location.X + parentTabPage.GetDesktopPanel().AutoScrollPosition.X, c.Location.Y + parentTabPage.GetDesktopPanel().AutoScrollPosition.Y)); foreach (Control c2 in parentTabPage.GetDesktopPanel().Controls) { if (c2.GetType() != typeof(Scale)) { continue; } Scale scale = (Scale)c2; if (innerBitmap.elementName == scale.elementName) { continue; } if (scale.Location == innerBitmap.Location) { Image front = null; foreach (Control c3 in scale.Controls) { if (c3.GetType() != typeof(PictureBox)) { continue; } if (c3.Name == "pictureBox1") { front = ((PictureBox)c3).Image; } } Image back = innerBitmap.activeImage; back = ImageBlend.ResizeImage(back, (int)(back.Width * scale.scale), (int)(back.Height * scale.scale)); //ImageBlend.Blend(back, front); scale.ApplyMask(new Bitmap(back)); } } } } parentTabPage.GetDesktopPanel().Refresh(); }
internal void Apply(string name, int x, int y, float scale, string imageName, int side, bool invert, string overlayImageName, Point overlayOffset, float overlayScale, string clicker) { if (name != "") { elementName = name; } Location = new Point(x, y); ChangeScale(scale); this.imageName = imageName; string path = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\gui\" + imageName + ".png"; ApplyImage(path); pictureBox1.Image = ImageBlend.MergeWithPanel(parentTabPage.GetDesktopPanel(), new Bitmap(pictureBox1.Image), new Point(Location.X + parentTabPage.GetDesktopPanel().AutoScrollPosition.X, Location.Y + parentTabPage.GetDesktopPanel().AutoScrollPosition.Y)); this.overlayImageName = overlayImageName; path = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\gui\" + overlayImageName + ".png"; this.overlayScale = overlayScale; try { overlayImage = Bitmap.FromFile(path); } catch (ArgumentException) { MessageBox.Show("Отсутствует файл " + path + ". Добавьте его и загрузите заново"); overlayImage = Resources._default_slot_empty; overlayImageName = "_default_slot_empty.png"; } overlayEnabled = true; pictureBox2.Visible = true; pictureBox2.Size = overlayImage.Size; pictureBox2.Image = new Bitmap(overlayImage); pictureBox2.Scale(new SizeF(overlayScale, overlayScale)); pictureBox2.Location = overlayOffset; ImageBlend.Blend(pictureBox1.Image, pictureBox2.Image); chosenItem = side; this.invert = invert; Clicker = clicker; }
public void ApplyMask(Bitmap image) { ImageBlend.MergeWithPanel(parentTabPage.GetDesktopPanel(), new Bitmap(image), new Point(Location.X + parentTabPage.GetDesktopPanel().AutoScrollPosition.X, Location.Y + parentTabPage.GetDesktopPanel().AutoScrollPosition.Y)); ImageBlend.Blend(image, activeImage); BackgroundImage = ImageBlend.ResizeImage(image, Width, Height); }