当前位置: 首页>>代码示例>>C#>>正文


C# Image.GetThumbnailImageAbort类代码示例

本文整理汇总了C#中Image.GetThumbnailImageAbort的典型用法代码示例。如果您正苦于以下问题:C# Image.GetThumbnailImageAbort类的具体用法?C# Image.GetThumbnailImageAbort怎么用?C# Image.GetThumbnailImageAbort使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Image.GetThumbnailImageAbort类属于命名空间,在下文中一共展示了Image.GetThumbnailImageAbort类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetThumbnail

 private void GetThumbnail(PaintEventArgs e)
 {
     Image.GetThumbnailImageAbort callback =
         new Image.GetThumbnailImageAbort(ThumbnailCallback);
     if (flag == 1)
     {
         for (int j = 0; j < 4; ++j)
         {
             for (int i = 0; i < 4; ++i)
             {
                 Image image = new Bitmap(filePaths[j * 4 + i]);
                 Image pThumbnail = image.GetThumbnailImage(200, 150, callback, new
                    IntPtr());
                 //label1.Text = filePaths[j*2 +i];
                 e.Graphics.DrawImage(
                    pThumbnail,
                    i * 230 + 20,
                    j * 160 + 10,
                    pThumbnail.Width,
                    pThumbnail.Height);
                 image = null;
                 pThumbnail = null;
                 GC.Collect();
             }
         }
     }
 }
开发者ID:kunalgrover05,项目名称:Windows-Photo-viewer,代码行数:27,代码来源:Form1.cs

示例2: ScaleImage

        public static Image ScaleImage(Image ImageToScale, double ScaledToHeight, double ScaleToWidth)
        {
            //Hold the min value. Is it the height or the width - Figure out which is the minimum value...the width or the height. Keeps the ratio
            double ScalingValue = Math.Min((ScaleToWidth / ImageToScale.Width), (ScaledToHeight / ImageToScale.Height));

            //Set the final scaled width
            double ScaledWidth = (ScalingValue * ImageToScale.Width);

            //Set the final scaled height
            double ScaledHeight = (ScalingValue * ImageToScale.Height);

            //set the callback to the private method - ThumbnailCallback
            //just use a lamda since the method doesn't do anything
            Image.GetThumbnailImageAbort CallBackForConversion = new Image.GetThumbnailImageAbort(() =>
            {
                try
                {
                    return false;
                }
                catch (Exception)
                {
                    throw;
                }
            });

            //return the image that is going to be scaled
            return ImageToScale.GetThumbnailImage(Convert.ToInt32(ScaledWidth), Convert.ToInt32(ScaledHeight), CallBackForConversion, IntPtr.Zero);
        }
开发者ID:dibiancoj,项目名称:ToracLibrary,代码行数:28,代码来源:ImageScaling.cs

示例3: scaleBitmap

        private Bitmap scaleBitmap(Bitmap bmp, PictureBox picBox)
        {
            float ratio = 1.0f;
            int thumbHeight = 0;
            int thumbWidth = 0;

            if (bmp.Height > picBox.Height || bmp.Width > picBox.Width)
            {
                Image.GetThumbnailImageAbort myCallback =
                    new Image.GetThumbnailImageAbort(ThumbnailCallback);

                if (bmp.Height >= bmp.Width)
                {
                    ratio = (((float)bmp.Width) / ((float)bmp.Height));
                    thumbHeight = picBox.Height;
                    thumbWidth = (int)((thumbHeight) * (ratio));
                }
                else
                {
                    ratio = (((float)bmp.Height) / ((float)bmp.Width));
                    thumbWidth = picBox.Width;
                    thumbHeight = (int)((thumbWidth) * (ratio));
                }

                Image myThumbnail = bmp.GetThumbnailImage(thumbWidth, thumbHeight, myCallback, IntPtr.Zero);
                return new Bitmap(myThumbnail);
            }
            return bmp;
        }
开发者ID:radol91,项目名称:BitMapEditorSolution,代码行数:29,代码来源:FormViewer.cs

示例4: GenerateThumbnail

        public void GenerateThumbnail(Stream imgFileStream, Stream thumbStream)
        {
            Image.GetThumbnailImageAbort callback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
            Bitmap bitmap = new Bitmap(imgFileStream);
            int thumbWidth = MaxThumbWidth;
            int thumbHeight = MaxThumbHeight;
            if (bitmap.Width > bitmap.Height)
            {
                thumbHeight = Decimal.ToInt32(((Decimal)bitmap.Height / bitmap.Width) * thumbWidth);
                if (thumbHeight > MaxThumbHeight)
                {
                    thumbHeight = MaxThumbHeight;
                }
            }
            else
            {
                thumbWidth = Decimal.ToInt32(((Decimal)bitmap.Width / bitmap.Height) * thumbHeight);
                if (thumbWidth > MaxThumbWidth)
                {
                    thumbWidth = MaxThumbWidth;
                }
            }

            Image thumbnail = bitmap.GetThumbnailImage(thumbWidth, thumbHeight, callback, IntPtr.Zero);

            thumbnail.Save(thumbStream,ImageFormat.Jpeg);
        }
开发者ID:TellagoDevLabs,项目名称:CloudPoint,代码行数:27,代码来源:ImageProcessor.cs

示例5: Thumbnail

 public ActionResult Thumbnail(string path)
 {
     var myCallback =
         new Image.GetThumbnailImageAbort(ThumbnailCallback);
     var paths = new List<string>(2);
     BuildPath(path, out folderPath, out resourcePath);
     var folder = session.OpenFolder(folderPath + "/");
     var resource = folder.GetResource(resourcePath + "/");
     var sourceStream = resource.GetReadStream();
     Bitmap bitmap = null;
     try
     {
         bitmap = new Bitmap(sourceStream);
     }
     catch (Exception)
     {
         var fs = new FileStream(Server.MapPath("~/Content/kendo/2014.2.716/Bootstrap/imagebrowser.png"), FileMode.Open);
         var tempBs = new byte[fs.Length];
         fs.Read(tempBs, 0, tempBs.Length);
         return new FileContentResult(tempBs, "image/jpeg");
     }
     var myThumbnail = bitmap.GetThumbnailImage(84, 70, myCallback, IntPtr.Zero);
     var ms = new MemoryStream();
     var myEncoderParameters = new EncoderParameters(1);
     var myEncoderParameter = new EncoderParameter(Encoder.Quality, 25L);
     myEncoderParameters.Param[0] = myEncoderParameter;
     myThumbnail.Save(ms, GetEncoderInfo("image/jpeg"), myEncoderParameters);
     ms.Position = 0;
     var bytes = ms.ToArray();
     return new FileContentResult(bytes, "image/jpeg");
 }
开发者ID:lxh2014,项目名称:gigade-net,代码行数:31,代码来源:ImageBrowserController.cs

示例6: GetImage

 /// <summary>
 /// 生成缩略图,返回缩略图的Image对象
 /// </summary>
 /// <param name="Width">缩略图宽度</param>
 /// <param name="Height">缩略图高度</param>
 /// <returns>缩略图的Image对象</returns>
 public Image GetImage(int Width, int Height)
 {
     Image img;
     Image.GetThumbnailImageAbort callb = new Image.GetThumbnailImageAbort(ThumbnailCallback);
     img = srcImage.GetThumbnailImage(Width, Height, callb, IntPtr.Zero);
     return img;
 }
开发者ID:szwork2013,项目名称:travel,代码行数:13,代码来源:Thumbnail.cs

示例7: Form1

        public Form1()
        {
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;
            myCallback = new Image.GetThumbnailImageAbort(CallBack);

            listener = new TcpListener(ipAddress, 8210);
        }
开发者ID:JBASKEY,项目名称:android-video-conference,代码行数:8,代码来源:Form1.cs

示例8: GetThumbNail

        public Image GetThumbNail( Image image, int new_width, int new_height )
        {
            Image.GetThumbnailImageAbort thumbnailCallback = new Image.GetThumbnailImageAbort( DummyThumbnailCallback );

            Image thumbnail = image.GetThumbnailImage( new_width, new_height, thumbnailCallback, IntPtr.Zero );

            return thumbnail;
        }
开发者ID:mono,项目名称:winforms-tools,代码行数:8,代码来源:ResourceBase.cs

示例9: Example_GetThumb

        public void Example_GetThumb(PaintEventArgs e)
        {
            Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
            Bitmap myBitmap = new Bitmap("Climber.jpg");
            Image myThumbnail = myBitmap.GetThumbnailImage(40, 40, myCallback, IntPtr.Zero);

            e.Graphics.DrawImage(myThumbnail, 150, 75);
        }
开发者ID:engineer9090909090909090,项目名称:foxriver,代码行数:8,代码来源:Form1.cs

示例10: RGBFilter

        public RGBFilter(BQPaint f)
        {
            InitializeComponent();
            this.f = f;
            Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);

            copy = f.main_bitmap.GetThumbnailImage(120, 120, myCallback, IntPtr.Zero);
            thumbnail.Image = copy;
        }
开发者ID:busiq,项目名称:bq-paint,代码行数:9,代码来源:RGBFilter.cs

示例11: GenerateThumb

    public void GenerateThumb(string imageInPath, string thumbOutPath)
    {
        log.Info("GenerateThumb(" + imageInPath + ", " + thumbOutPath + ")");

        try {
            if (Directory.Exists(thumbOutPath.Substring(0,thumbOutPath.LastIndexOf("/"))) == false)
                Directory.CreateDirectory(thumbOutPath.Substring(0,thumbOutPath.LastIndexOf("/")));

            using (Image imageIn = System.Drawing.Image.FromFile(imageInPath)) {

                int width = thumbWidth;
                int height = thumbHeight;

                /* Is the image smaller than our thumbnail size? */

                if (imageIn.Width < thumbWidth)
                    width = imageIn.Width;

                if (imageIn.Height < thumbHeight)
                    height = imageIn.Height;

                /* Is the image tall ? */

                if (imageIn.Height > imageIn.Width) {
                    height = thumbHeight;
                    width = Convert.ToInt32 ((double)height * ((double)imageIn.Width / (double)imageIn.Height));
                }

                /* Is the image wide ? */

                if (imageIn.Height < imageIn.Width) {
                    width = thumbWidth;
                    height = Convert.ToInt32( (double)width * ((double)imageIn.Height / (double)imageIn.Width) );
                }

                /* Center the thumbnail */

                int x = (thumbWidth / 2) - (width /2);
                int y = (thumbHeight / 2) - (height /2);

                Console.WriteLine ("New Thumb: " + x + " " + y + " " + width + " " + height);
                Image.GetThumbnailImageAbort dummyCallback = new Image.GetThumbnailImageAbort (ThumbnailCallback);
                Image thumbImage = imageIn.GetThumbnailImage (width, height, dummyCallback, IntPtr.Zero);
                Bitmap imageOut = new Bitmap (thumbWidth, thumbHeight);
                Graphics graphicsOut = Graphics.FromImage (imageOut);
                graphicsOut.Clear (Color.Gray);
                graphicsOut.DrawImage (thumbImage, x, y);
                imageOut.Save (thumbOutPath, ImageFormat.Jpeg);

            }

        } catch (Exception ex) {
            log.Error("Exception in GenerateThumb!", ex);
            throw ex;
        }
    }
开发者ID:MonoBrasil,项目名称:historico,代码行数:56,代码来源:QuickThumbs.cs

示例12: GetThumbnail

 /// <summary>  
 /// 生成缩略图,返回缩略图的Image对象  
 /// </summary>  
 /// <param name="path">原图片全路径</param>  
 /// <param name="width">缩略图的宽度</param>  
 /// <param name="height">缩略图的高度</param>  
 /// <returns>缩略图的Image对象</returns>  
 public static Image GetThumbnail(string path,int width, int height)
 {
     try
     {
         Image resourceImage = Image.FromFile(path);//获取原图
         Image.GetThumbnailImageAbort callb = new Image.GetThumbnailImageAbort(ThumbnailCallback);
         return resourceImage.GetThumbnailImage(width, height, callb, IntPtr.Zero);
     }
     catch{return null;}
 }
开发者ID:wx5050520,项目名称:Bode,代码行数:17,代码来源:ImageHelper.cs

示例13: GetThumbnailImage

 public static Response GetThumbnailImage(Guid id, int page, IResponseFormatter response)
 {
     var bitmap = Image.FromStream(new MemoryStream(GetPageImageBytes(id, page)), false, false);
     double ratio = 200D / (double)bitmap.Height;
     int width = (int)(bitmap.Width * ratio);
     var callback = new Image.GetThumbnailImageAbort(() => true);
     var thumbnail = bitmap.GetThumbnailImage(width, 200, callback, IntPtr.Zero);
     MemoryStream stream = GetBytesFromImage(thumbnail);
     return response.FromStream(stream, MimeTypes.GetMimeType(".jpg"));
 }
开发者ID:kavenblog,项目名称:ComicRackWeb,代码行数:10,代码来源:API.cs

示例14: GenerateThumbnail

        /// <summary>
        /// Converts any bitmap down to a 96x96 square with linear x/y scaling and border whitespace if needed
        /// </summary>
        /// <param name="masterImage">Full size Bitmap of any dimension</param>
        /// <returns>96x96 Bitmap</returns>
        internal static Bitmap GenerateThumbnail(Bitmap masterImage)
        {
            Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);

            // Calculate the thumbnail size
            double newWidth = 0.0;
            double newHeight = 0.0;

            if (masterImage.Width > 96 || masterImage.Height > 96)
            {
                bool portrait = false;

                if (masterImage.Width > masterImage.Height)
                    portrait = true;

                if (portrait)
                {
                    double pct = (double)masterImage.Width / 96;
                    newWidth = (double)masterImage.Width / pct;
                    newHeight = (double)masterImage.Height / pct;
                }
                else
                {
                    double pct = (double)masterImage.Height / 96;
                    newWidth = (double)masterImage.Width / pct;
                    newHeight = (double)masterImage.Height / pct;
                }
            }
            else
            {
                newWidth = masterImage.Width;
                newHeight = masterImage.Height;
            }

            Image myThumbnail = masterImage.GetThumbnailImage((int)newWidth,(int)newHeight,myCallback,IntPtr.Zero);

            // Put the thumbnail on a square background
            Bitmap squareThumb = new Bitmap(96,96);
            Graphics g = Graphics.FromImage(squareThumb);

            int x = 0;
            int y = 0;

            x = (96 - myThumbnail.Width) / 2;
            y = (96 - myThumbnail.Height) / 2;

            g.DrawImage(myThumbnail, new Rectangle(new Point(x,y), new Size(myThumbnail.Width, myThumbnail.Height)));


            // Write out the new bitmap
            MemoryStream ms = new MemoryStream();
            squareThumb.Save(ms, ImageFormat.Png);
            return new Bitmap(ms);
        }
开发者ID:psyCHOder,项目名称:conferencexp,代码行数:59,代码来源:Utilities.cs

示例15: ProcessRequest

    public void ProcessRequest(HttpContext context)
    {
        string ImageUrl = context.Request.QueryString["url"];
        //get image width to be resized from querystring
        string ImageWidth = context.Request.QueryString["width"];
        //get image height to be resized from querystring
        string ImageHeight = context.Request.QueryString["height"];
        if (ImageUrl != string.Empty && ImageHeight != string.Empty && ImageWidth != string.Empty && (ImageWidth != null && ImageHeight != null))
        {
            if (!System.Web.UI.WebControls.Unit.Parse(ImageWidth).IsEmpty && !System.Web.UI.WebControls.Unit.Parse(ImageHeight).IsEmpty)
            {
                Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
                //creat BitMap object from image path passed in querystring
                Bitmap BitmapForImage = new Bitmap(context.Server.MapPath(ImageUrl));
                //create unit object for height and width. This is to convert parameter passed in differen unit like pixel, inch into generic unit.
                System.Web.UI.WebControls.Unit WidthUnit = System.Web.UI.WebControls.Unit.Parse(ImageWidth);
                System.Web.UI.WebControls.Unit HeightUnit = System.Web.UI.WebControls.Unit.Parse(ImageHeight);
                //Resize actual image using width and height paramters passed in querystring
                Image CurrentThumbnail = BitmapForImage.GetThumbnailImage(Convert.ToInt16(WidthUnit.Value), Convert.ToInt16(HeightUnit.Value), myCallback, IntPtr.Zero);
                //Create memory stream and save resized image into memory stream
                MemoryStream objMemoryStream = new MemoryStream();
                if (ImageUrl.EndsWith(".png"))
                {
                    context.Response.ContentType = "image/png";
                    CurrentThumbnail.Save(objMemoryStream, System.Drawing.Imaging.ImageFormat.Png);
                }
                else if (ImageUrl.EndsWith(".jpg"))
                {
                    context.Response.ContentType = "image/jpeg";
                    CurrentThumbnail.Save(objMemoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                }
                else if (ImageUrl.EndsWith(".gif"))
                {
                    context.Response.ContentType = "image/gif";
                    CurrentThumbnail.Save(objMemoryStream, System.Drawing.Imaging.ImageFormat.Gif);
                }

                //Declare byte array of size memory stream and read memory stream data into array
                byte[] imageData = new byte[objMemoryStream.Length];
                objMemoryStream.Position = 0;
                objMemoryStream.Read(imageData, 0, (int)objMemoryStream.Length);

                //send contents of byte array as response to client (browser)
                context.Response.BinaryWrite(imageData);
            }
        }
        else
        {
            //if width and height was not passed as querystring, then send image as it is from path provided.
            context.Response.WriteFile(context.Server.MapPath(ImageUrl));
        }
    }
开发者ID:Saroko-dnd,项目名称:My_DZ,代码行数:52,代码来源:HttpRequestForResizingOfImages.cs


注:本文中的Image.GetThumbnailImageAbort类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。