private void CreateCustomMask(MaskType circle) { LoadedMask = "custom "; var bmpTemp = new Bitmap(512, 512); var G = Graphics.FromImage(bmpTemp); G.Clear(Color.Black); G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; G.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; G.FillEllipse(Brushes.White, 20, 20, 512 - 40, 512 - 40); Mask = new Bitmap(bmpTemp); Output = new Bitmap(Mask.Width, Mask.Height); ArtRender.BuildTree(Mask, TheSettings); TheSettings.ReloadMask = false; UpdateFunc(); this.Height = Mask.Height + 40; this.Width = Mask.Width + 20; }
public void UpdateFunc() { if (TheSettings.ReloadMask) { TheSettings.ReloadMask = false; LoadMask(LoadedMask); return; } pictureBox1.Invalidate(); // pictureBox2.Invalidate(); if (Mask == null) { return; } ArtRender.BuildStuff(Mask, TheSettings); }
private void pictureBox2_Paint(object sender, PaintEventArgs e) { if (Mask == null) { e.Graphics.Clear(Color.Gray); e.Graphics.DrawString("Load a mask first!", new Font("Arial", 13), Brushes.Black, new PointF(10, 10)); return; } Graphics G = Graphics.FromImage(Output); G.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; ArtRender.DrawTiling(TheSettings, Mask, G, Color.White, Color.Black, 1); e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; float aspect = pictureBox1.Width / (float)pictureBox1.Height; float maskaspect = Mask.Width / (float)Mask.Height; float scale = 1.0f; if (maskaspect > aspect) { scale = pictureBox1.Width / (float)Mask.Width; } else { scale = pictureBox1.Height / (float)Mask.Height; } e.Graphics.ScaleTransform(scale, scale); e.Graphics.DrawImage(Output, 0, 0); }