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


C# Image.GetThumbnailImage方法代码示例

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


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

示例1: EnsureMaximumDimensions

        public static Image EnsureMaximumDimensions(Image image, int maxWidth, int maxHeight)
        {
            // Prevent using images internal thumbnail
            image.RotateFlip(RotateFlipType.Rotate180FlipNone);
            image.RotateFlip(RotateFlipType.Rotate180FlipNone);

            var aspectRatio = ((double)image.Width) / image.Height; //AR = L/A;

            int imageWidth = image.Width;
            int imageHeight = image.Height;

            if (imageWidth > maxWidth)
            {
                imageWidth = maxWidth;
                imageHeight = (int)(imageWidth / aspectRatio);
            }
            if (imageHeight > maxHeight)
            {
                imageHeight = maxHeight;
                imageWidth = (int)(imageHeight * aspectRatio);
            }

            if (image.Width != imageWidth || image.Height != imageHeight)
                return image.GetThumbnailImage(imageWidth, imageHeight, null, IntPtr.Zero);

            return image;
        }
开发者ID:andrerpena,项目名称:Cerebello,代码行数:27,代码来源:ImageHelper.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: newPBox_Click

 public void newPBox_Click(object sender, EventArgs e)
 {
     string newIcon = ((PictureBox)sender).Tag.ToString();
       workingImage = Image.FromFile(newIcon);
       pbCurrentIcon.Image = workingImage.GetThumbnailImage(128, 128, null, new IntPtr());
       workingImage.Dispose();
       buttonTexture = newIcon;
 }
开发者ID:damienhaynes,项目名称:streamedmp,代码行数:8,代码来源:getButtonTexture.cs

示例4: 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

示例5: CreateThumbnail

        /// <summary>
        /// create a thumbnail from the original image
        /// </summary>
        /// <param name="originalImage">the original image from which the thumbnail is created</param>
        /// <param name="imageHeight">the height of the thumbnail</param>
        /// <returns></returns>
        public static Image CreateThumbnail(Image originalImage, int imageHeight)
        {
            // create thumbnail
            float ratio = (float)originalImage.Width / originalImage.Height;
            int imageWidth = (int)(imageHeight * ratio);

            // set the thumbnail image
            Image thumbnailImage = originalImage.GetThumbnailImage(imageWidth, imageHeight,
                new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);

            return thumbnailImage;
        }
开发者ID:anndream,项目名称:anpr-1,代码行数:18,代码来源:Util.cs

示例6: GetThumbnail

        /// <summary>
        ///     Gets a thumbnail image that represents the specified <paramref name="image"/>.
        /// </summary>
        /// <param name="image">The image.</param>
        /// <param name="width">The thumbnail image width.</param>
        /// <param name="height">The thumbnail image height.</param>
        /// <returns>The thumbnail image.</returns>
        public static Image GetThumbnail(Image image, int width, int height)
        {
            Check.Require<ArgumentNullException>(image != null, "image");
            Check.Require<ArgumentOutOfRangeException>(width > 0, "width");
            Check.Require<ArgumentOutOfRangeException>(height > 0, "height");

            return image.GetThumbnailImage(
                width,
                height,
                () => false,
                IntPtr.Zero);
        }
开发者ID:sandord,项目名称:Subspace.Imaging,代码行数:19,代码来源:ImageResizingUtils.cs

示例7: UpdateImage

        public void UpdateImage(Image image, float thumbnailCoef)
        {
            int deltHeight = this.Height - this.pictureBox1.Height;
            int deltWidth = this.Width - this.pictureBox1.Width;

            Size thumbnailSize = new Size((int)(image.Width * thumbnailCoef), (int)(image.Height * thumbnailCoef));
            this.Size = new Size(thumbnailSize.Width + deltWidth, thumbnailSize.Height + deltHeight);                       
            
            System.Drawing.Image.GetThumbnailImageAbort myCallBack = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallBack);

            Image thumbnail = image.GetThumbnailImage(thumbnailSize.Width, thumbnailSize.Height, myCallBack, IntPtr.Zero);//生成缩略图
            this.pictureBox1.Image = thumbnail;   
        }
开发者ID:maanshancss,项目名称:ClassLibrary,代码行数:13,代码来源:Thumbnail.cs

示例8: Scale

        public static Image Scale(Image img, int maxWidth, int maxHeight, double scale)
        {
            if (img.Width > maxWidth || img.Height > maxHeight)
            {
                double scaleW, scaleH;

                scaleW = maxWidth / (double)img.Width;
                scaleH = maxHeight / (double)img.Height;

                scale = scaleW < scaleH ? scaleW : scaleH;
            }

            return img.GetThumbnailImage((int)(img.Width * scale), (int)(img.Height * scale), null, IntPtr.Zero);
        }
开发者ID:RavenB,项目名称:OpenTools,代码行数:14,代码来源:ScrollablePicturebox.cs

示例9: CreateThumbnail

        /// <summary>
        /// Creates a thumbnail from the image provided, scaled down to the
        /// new height specified while keeping the aspect ratio
        /// </summary>
        /// <param name="fullImage">The image to replicate</param>
        /// <param name="newHeight">The new height to scale to</param>
        /// <returns>Returns a thumbnail Image</returns>
        public Image CreateThumbnail(Image fullImage, int newHeight)
        {
            Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
            int newWidth;
            if (fullImage.Height > fullImage.Width)
            {
                newWidth = Convert.ToInt32(Math.Round((double) ((fullImage.Height/fullImage.Width)*newHeight)));
            }
            else
            {
                newWidth = Convert.ToInt32(Math.Round((double) ((fullImage.Width/fullImage.Height)*newHeight)));
            }

            return fullImage.GetThumbnailImage(newWidth, newHeight, myCallback, IntPtr.Zero);
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:22,代码来源:ImageThumbnailCreator.cs

示例10: Negative

        public Negative(Image image, int width = 0, int height = 0)
        {
            if (width != height)
            {
                double ratio = width >= height ? (double)image.Height / image.Width : (double)image.Width / image.Height;
                if (width == 0)
                    width = (int)(height * ratio);
                if (height == 0)
                    height = (int)(width * ratio);
            }

            if (width == 0 && height == 0)
                _image = image;
            else _image = image.GetThumbnailImage(width, height, null, IntPtr.Zero);
        }
开发者ID:vladjerca,项目名称:DarkRoom,代码行数:15,代码来源:Negative.cs

示例11: ResizeImage

        public Image ResizeImage( Image fullsizeImage, int newWidth )
        {
            // Prevent using images internal thumbnail
            fullsizeImage.RotateFlip( System.Drawing.RotateFlipType.Rotate180FlipNone );
            fullsizeImage.RotateFlip( System.Drawing.RotateFlipType.Rotate180FlipNone );

            var newHeight = fullsizeImage.Height * newWidth / fullsizeImage.Width;
            
            var newImage = fullsizeImage.GetThumbnailImage( newWidth, newHeight, null, IntPtr.Zero );

            // Clear handle to original file so that we can overwrite it if necessary
            fullsizeImage.Dispose();

            // Save resized picture
            return newImage;
        }
开发者ID:bsommardahl,项目名称:FlickTrap,代码行数:16,代码来源:ImageController.cs

示例12: populateScreen

 void populateScreen(string theme)
 {
     iconFiles.Clear();
       flThemeButtons.Controls.Clear();
       themePreview.Image = Image.FromFile(Path.Combine(Path.Combine(streamedMPMediaPath, "homebuttons"), theme + "themepreview.jpg"));
       iconList(theme);
       foreach (string icon in iconFiles)
       {
     PictureBox newPBox = new PictureBox();
     newPBox.Size = new Size(64, 64);
     workingImage = Image.FromFile(icon);
     newPBox.Image = workingImage.GetThumbnailImage(64, 64, null, new IntPtr());
     workingImage.Dispose();
     flThemeButtons.Controls.Add(newPBox);
       }
 }
开发者ID:MichelZ,项目名称:streamedmp-michelz,代码行数:16,代码来源:showButtonTheme.cs

示例13: LowQualityScaledThumbnail

 public static Image LowQualityScaledThumbnail(Image iImage,
     Int32 iMaxWidth,
     Int32 iMaxHeight)
 {
     Double pDblRatio = 0;
     if (iImage.Width > iImage.Height)
     {
         pDblRatio = (Double)iMaxWidth / iImage.Width;
     }
     else
     {
         pDblRatio = (Double)iMaxHeight / iImage.Height;
     }
     Double pDblRescaledWidth = iImage.Width * pDblRatio;
     Double pDblRescaledHeight = iImage.Height * pDblRatio;
     return (iImage.GetThumbnailImage((Int32)pDblRescaledWidth, (Int32)pDblRescaledHeight, null, IntPtr.Zero));
 }
开发者ID:devoctomy,项目名称:knitup,代码行数:17,代码来源:DrawingUtility.cs

示例14: ResizeImage

        internal void ResizeImage(Image source, Stream stream)
        {
            if (source == null)
                throw new ArgumentNullException("source");

            Size size = DetermineScalingSize(source, _widthThreshold, _heightThreshold);

            ImageConverter imageConverter = new ImageConverter();

            using (Image resized = source.GetThumbnailImage(size.Width, size.Height, () => false, IntPtr.Zero))
            {
                ImageCodecInfo jpgEncoder = GetEncoderInfo("image/jpeg");
                using (EncoderParameters encoderParameters = GetEncodeParamaters(_compression))
                {
                    resized.Save(stream, jpgEncoder, encoderParameters);
                }
            }
        }
开发者ID:pirovorster,项目名称:ServiceHub,代码行数:18,代码来源:ImageResizer.cs

示例15: LoadImage

        private void LoadImage(Image image)
        {
            this.CalculateTextSize();
            _szText.Height += 4;
            this.Height += _szText.Height + GAP_SIZE_SHADOW;
            this.Width += GAP_SIZE_SHADOW;

            Rectangle rc = this.ClientRectangle;
            _rcClient = new Rectangle(rc.Left + GAP_OFFSET_SHADOW, rc.Top + GAP_OFFSET_SHADOW,
                                      rc.Width - GAP_SIZE_SHADOW, rc.Height - GAP_SIZE_SHADOW);

            using (image)
            {
                _imageThumbnail = image.GetThumbnailImage(_rcClient.Width - GAP_SIZE,
                                                        _rcClient.Height - _szText.Height - GAP_SIZE,
                                                        null, IntPtr.Zero);
            }
        }
开发者ID:sreenandini,项目名称:test_buildscripts,代码行数:18,代码来源:PreviewWidget.cs


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