public static void DrawAnnouncement(Bitmap B, AnnouncementDetails AD) { Graphics G = Graphics.FromImage(B); Bitmap B2 = new Bitmap(B.Width, B.Height); Graphics G2 = Graphics.FromImage(B2); G2.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; G2.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; G.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; G2.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; G.Clear(Color.Black); if (AD.Background != null) { RectangleF From = new RectangleF(0, 0, AD.Background.Width, AD.Background.Height); RectangleF To = new RectangleF(0, 0, B.Width, B.Height); if (From.Width > To.Width || From.Height > To.Height) { double fromas = From.Width / From.Height; double toas = To.Width / To.Height; double scale = 1; if (fromas < toas) { scale = From.Width / To.Width; From.Y = From.Height / 2 - (float)(To.Height * scale) / 2; From.Height = (float)(To.Height * scale); } else { scale = From.Height / To.Height; From.X = From.Width / 2 - (float)(To.Width * scale) / 2; From.Width = (float)(To.Width * scale); } Console.WriteLine("{0}", scale); } G.DrawImage(AD.Background, To, From, GraphicsUnit.Pixel); } for (int i = 0; i < 5; i++) { DrawTo(AD, G2, 10 + i * 5, true); } TINRSArtWorkRenderer ArtRender = new TINRSArtWorkRenderer(); Settings TheSettings = new Settings(); TheSettings.InvertSource = false; TheSettings.DegreesOff = 14; //TheSettings.MaxSubDiv; ArtRender.BuildTree(B2, TheSettings); ArtRender.BuildStuff(B2, TheSettings); ArtRender.DrawTiling(TheSettings, B2, G, Color.Yellow, Color.Black, 1.2f, false); DrawTo(AD, G, 2, false); }
public static void DrawIcon(int w, int h, Graphics G, string Label, float huerange = -1) { Bitmap Output = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(Output); TINRSArtWorkRenderer Rend = new TINRSArtWorkRenderer(); Settings TheSettings = Rend.GetHashSettings(Label, huerange); TheSettings.InvertSource = true; //TheSettings.MaxSubDiv = 4; Bitmap TileGfx = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format32bppArgb); Graphics G3 = Graphics.FromImage(TileGfx); G3.Clear(Color.Transparent); float D = 2; float x1 = D / 2; float x2 = w - x1; float y1 = D / 2; float y2 = h - x1; Font F = new Font("Panton ExtraBold", h * 0.5f, FontStyle.Bold); F = GetAdjustedFont(g, Label, F, w * 0.9f, h * 0.9f, 3, false); var S = g.MeasureString(Label, F); var S2 = g.MeasureString("WO", F); S.Height = S2.Height; float BaseScale = w / 128.0f; GraphicsPath GP = new GraphicsPath(); GP.AddString(Label, new FontFamily("Panton ExtraBold"), 0, F.Size * 1.333333f, new PointF(w / 2 - S.Width / 2, h / 2 - S.Height / 2), new StringFormat()); Bitmap M = new Bitmap(w, h); Graphics G2 = Graphics.FromImage(M); G2.Clear(Color.White); G2.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; G2.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; G2.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; G2.SmoothingMode = SmoothingMode.AntiAlias; RenderIconBackdrop(G2, Color.Black, TheSettings, x1, x2, y1, y2, 2, Rend); G2.DrawPath(new Pen(Color.Black, 5), GP); // G2.DrawString(Letter.Text, F, new SolidBrush(Color.White), w / 2 - S.Width / 2, h / 2 - S.Height / 2); G2.DrawPath(new Pen(Color.White, Math.Max(2.0f, 6 * BaseScale)), GP); G2.FillPath(new SolidBrush(Color.White), GP); g.DrawPath(new Pen(TheSettings.BackGroundColor, 5), GP); Rend.BuildTree(M, TheSettings); Rend.BuildStuff(M, TheSettings); g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; g.SmoothingMode = SmoothingMode.AntiAlias; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; float BaseScale2 = 1.0f; // g.FillPath(new SolidBrush(Color.Teal), GP); TheSettings = Rend.GetHashSettings(Label, huerange); RenderIconBackdrop(g, TheSettings.BackGroundColor, TheSettings, x1, x2, y1, y2, 0, Rend); Rend.DrawTiling(TheSettings, M, G3, Color.FromArgb(40, Color.Black), Color.Black, Math.Max(3, 4.5f * BaseScale2), false); Rend.DrawTiling(TheSettings, M, G3, TheSettings.BackgroundHighlight, Color.Black, Math.Max(1.4f, 3 * BaseScale2), false); Rend.DrawTiling(TheSettings, M, G3, Color.FromArgb(100, 255, 255, 0), Color.Black, Math.Max(1.0f, 1.4f * BaseScale2), false); for (var i = 0; i < h; i++) { for (var j = 0; j < w; j++) { var C = Output.GetPixel(j, i); if (C.A > 0) { var TP = TileGfx.GetPixel(j, i); var C2 = GerberLibrary.MathHelpers.Interpolate(C, TileGfx.GetPixel(j, i), TP.A / 255.0f); Output.SetPixel(j, i, Color.FromArgb(C.A, C2)); } } } g.DrawPath(new Pen(Color.FromArgb(60, Color.Black), 3), GP); g.FillPath(new SolidBrush(Color.FromArgb(255, 255, 255)), GP); G.DrawImage(Output, 0, 0); }