Exemple #1
0
        /*
        //beolvassa a képet bytonként ésúgy szúrja be a htmlbe
        string s = "<img src=\"" + getImageFromFile("~/Content/skin/Office2010Blue.png", "image/png") + "\" style=\"width: 100px;height: 100px;\" />";
        var html = new HtmlDocument();

        @html.CreateElement(s)

        public string getImageFromFile(String url, String imgType)
        {
            using (FileStream fs = new FileStream(Server.MapPath(url),
                                           FileMode.Open,
                                           FileAccess.Read))
            {
                byte[] filebytes = new byte[fs.Length];
                fs.Read(filebytes, 0, Convert.ToInt32(fs.Length));
            }
            string encodedData = Convert.ToBase64String(filebytes);
            return "data:" + imgType + ";base64,+"encodedData;
        }
        */
        /// <summary>
        /// Képlopó, eg ywebbrowser képét adja vissza
        /// </summary>
        /// <param name="Browser1"></param>
        /// <returns></returns>
        public static Bitmap screen_img(WebBrowser Browser1)
        {
            var topLeftCorner = Browser1.PointToScreen(new Point(0, 0));
            var topLeftGdiPoint = new System.Drawing.Point((int)topLeftCorner.X, (int)topLeftCorner.Y);
            var size = new System.Drawing.Size((int)Browser1.Width, (int)Browser1.Height);
            Bitmap screenShot = new Bitmap(size.Width,size.Height);
                using (var graphics = Graphics.FromImage(screenShot))
                {
                    graphics.CopyFromScreen(topLeftGdiPoint, new System.Drawing.Point(),
                         size, CopyPixelOperation.SourceCopy);
                }
            return screenShot;
        }