private void ApplyOverlayImage() { pictureBox2.Size = overlayImage.Size; pictureBox2.Image = new Bitmap(overlayImage); pictureBox2.Scale(new SizeF(overlayScale, overlayScale)); ImageBlend.Blend(pictureBox1.Image, pictureBox2.Image); }
internal void Apply(string name, int x, int y, float scale, string imageName, 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); this.overlayImageName = overlayImageName; path = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\gui\" + overlayImageName + ".png"; this.overlayScale = overlayScale; try { overlayImage = Bitmap.FromFile(path); } catch (Exception) { 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, overlayImage); this.clicker = clicker; }
private void PictureBox2_VisibleChanged(object sender, EventArgs e) { if (overlayEnabled) { ImageBlend.Blend(pictureBox1.Image, pictureBox2.Image); } }
private void _overlaySizeValue_LostFocus(object sender, EventArgs e) { if (constant) { return; } if (!overlayEnabled) { return; } if (!overlayScaleTextChanged) { return; } overlayScaleTextChanged = false; TextBox textBox = (TextBox)sender; float scale; if (!float.TryParse(textBox.Text, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out scale)) { textBox.Text = overlayScale.ToString(); return; } overlayScale = scale; pictureBox2.Scale(new SizeF(overlayScale, overlayScale)); if (overlayEnabled) { ImageBlend.Blend(pictureBox1.Image, pictureBox2.Image); } }
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)); }
private void TrackBar_ValueChanged(object sender, EventArgs e) { TrackBar trackBar = (TrackBar)sender; int value = trackBar.Value; if (!invert) { switch (chosenItem) { case 0: pictureBox1.Width = pictureBox1.Image.Size.Width * value / 100; SyncWithOverlay(); break; case 1: pictureBox1.Top = Height - Height * value / 100; pictureBox1.Image = ImageBlend.CropVertical(scaledActiveImage, value); SyncWithOverlay(); break; case 2: pictureBox1.Left = Width - Width * value / 100; pictureBox1.Image = ImageBlend.CropHorizontal(scaledActiveImage, value); SyncWithOverlay(); break; case 3: pictureBox1.Height = pictureBox1.Image.Size.Height * value / 100; SyncWithOverlay(); break; } } else { switch (chosenItem) { case 0: pictureBox1.Location = new Point(-Width * (100 - value) / 100, pictureBox1.Location.Y); SyncWithOverlay(); break; case 1: pictureBox1.Location = new Point(pictureBox1.Location.X, Height * (100 - value) / 100); SyncWithOverlay(); break; case 2: pictureBox1.Location = new Point(Width * (100 - value) / 100, pictureBox1.Location.Y); SyncWithOverlay(); break; case 3: pictureBox1.Location = new Point(pictureBox1.Location.X, -Height * (100 - value) / 100); SyncWithOverlay(); break; } } }
public override void ToDefault() { ActiveImage = _params.GetInvSlotImage(out string imageName); pictureBoxSlot.Image = new Bitmap(ActiveImage); ImageName = imageName; pictureBoxSelection.Image = new Bitmap(_params.GetSelectionImage(out imageName)); ImageBlend.Blend(pictureBoxSlot.Image, pictureBoxSelection.Image); Refresh(); }
public override void ChangeScale(float scale) { this.scale = scale; oldLocation = Location; ChangeControlSize(originSize); Scale(new SizeF(scale, scale)); pictureBox1.Image = ImageBlend.ResizeImage(pictureBox1.Image, Width, Height); Location = oldLocation; }
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(); }
public override void ChangeScale(float scale) { this.scale = scale; oldLocation = Location; ChangeControlSize(originSize); Scale(new SizeF(scale, scale)); pictureBox1.Image = ImageBlend.ResizeImage(pictureBox1.Image, Width, Height); pictureBox2.Size = overlayImage.Size; if (overlayEnabled) { overlayScale *= scale; pictureBox2.Scale(new SizeF(overlayScale, overlayScale)); pictureBox2.Image = ImageBlend.ResizeImage(pictureBox2.Image, pictureBox2.Width, pictureBox2.Height); } Location = oldLocation; }
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; }
internal void SetSelection(Image selectionDefaultImage) { pictureBoxSelection.Image = new Bitmap(selectionDefaultImage); ImageBlend.Blend(pictureBoxSlot.Image, pictureBoxSelection.Image); Refresh(); }
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); }