public void GenerateMap() { if (!wia) { var htmlToImage = new NReco.ImageGenerator.HtmlToImageConverter(); htmlToImage.GenerateImageFromFile(string.Format("http://{0}{1}?{2}", ws.Name, wp.Path, wp.QueryString), null, HttpContext.Current.Server.MapPath(string.Format("~/wpi/{0}-{1}.jpeg", ws.ID, wp.ID))); } Image img = Image.FromFile(HttpContext.Current.Server.MapPath(this.wpip)); using (Graphics g = Graphics.FromImage(img)) { using (SolidBrush transb = new SolidBrush(Color.FromArgb(180, 51, 51, 61)))//#33333D { g.FillRectangle(transb, 0, 0, img.Width, img.Height); } foreach (var i2 in Activities) { using (SolidBrush transb = new SolidBrush(Color.FromArgb(255, 255, 60, 0)))//#ff3c00 { g.FillEllipse(transb, i2.MouseClickX.Value - 10, i2.MouseClickY.Value - 10, 10, 10); } } } _hmpath = string.Format("~/heatmaps/{0}.png", Guid.NewGuid().ToString()); img.Save(HttpContext.Current.Server.MapPath(_hmpath), System.Drawing.Imaging.ImageFormat.Png); }
public static byte[] ConvertHtmlToImage(string url) { if (!string.IsNullOrEmpty(url)) { var htmlToImageConv = new NReco.ImageGenerator.HtmlToImageConverter(); return(htmlToImageConv.GenerateImageFromFile(url, ImageFormat.Jpeg.ToString())); } else { return(null); } }
public CanvasPicture(string fileName, Size parentSize) { InitializeComponent(); this.Size = parentSize; if (fileName.EndsWith(".svg")) { imageType = ImageType.Vector; var imageByte = svgImage.GenerateImageFromFile(fileName, "png"); var stream = new System.IO.MemoryStream(imageByte, 0, imageByte.Length); pictureBox.Image = new Bitmap(Image.FromStream(stream)); } else { imageType = ImageType.Raster; pictureBox.Image = new Bitmap(fileName); } this.Location = new Point(0, 0); this.Refresh(); }