Exemplo n.º 1
0
 public static Bitmap GetSiteThumbnail(string url, int width, int height, int thumbWidth, int thumbHeight,string absolutePath)
 {
     WebSiteThumbnail thumb = new WebSiteThumbnail(url, width, height, thumbWidth, thumbHeight,absolutePath );
     Bitmap b = thumb.GetScreenShot();
     if (b == null)
         b = (Bitmap)System.Drawing.Image.FromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("PAB.WebControls.Notavailable.jpg"));
      return b;
 }
        private void WebSiteThumbnailControl_Init(EventArgs e)
        {
            HttpRequest httpRequest = Context.Request;
            HttpResponse httpResponse = Context.Response;
            if (this.Bitmap == null)
            {
                PAB.WebControls.WebSiteThumbnail sh = new WebSiteThumbnail(this._siteUrl, this._siteWidth, this._siteHeight, this._thumbnailWidth, this._thumbnailHeight);
               this.Bitmap= sh.GetScreenShot();

            }
            if (httpRequest.Params[String.Concat("WebSiteThumbnailControl_", UniqueID)] != null)
            {
                httpResponse.Clear();
                if(this.ImageType==ImageType.Gif)
                {
                    httpResponse.ContentType = "Image/Gif";
                    //Bitmap.Save(httpResponse.OutputStream,ImageFormat.Gif );
                    // (ImageHandler class is an experiment based on some comments)
                    ImageHandler handler= new ImageHandler(Bitmap,"Image/Gif") ;
                    handler.ProcessRequest(HttpRuntime ) ;

                }
                else
                {
                    httpResponse.ContentType = "Image/Jpeg";
                    //Bitmap.Save(httpResponse.OutputStream, ImageFormat.Jpeg);
                               ImageHandler handler= new ImageHandler(Bitmap,"Image/Jpeg") ;
                               handler.ProcessRequest(HttpRuntime ) ;
                }
               // httpResponse.End();
            }
            string str = httpRequest.Url.ToString();
            if (str.IndexOf("?") == -1)
            {
                ImageUrl = String.Concat(str, "?WebSiteThumbnailControl_", UniqueID, "=1");
            }
            else
            {
                ImageUrl = String.Concat(str, "&WebSiteThumbnailControl_", UniqueID, "=1");
            }
        }