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


C# Bitmap.ResizeImage方法代码示例

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


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

示例1: ImageImport

        public static bool ImageImport(this DeviceModel deviceModel, Stream ImageStream)
        {
            try
            {
                using (Bitmap inputBitmap = new Bitmap(ImageStream))
                {
                    using (Image outputBitmap = inputBitmap.ResizeImage(256, 256))
                    {
                        using (MemoryStream ms = new MemoryStream())
                        {
                            outputBitmap.SavePng(ms);
                            ms.Position = 0;

                            var deviceModelImagePath = deviceModel.ImageFilePath();


                            using (var storeStream = new FileStream(deviceModelImagePath, FileMode.Create, FileAccess.Write, FileShare.None))
                            {
                                ms.CopyTo(storeStream);
                            }
                            //deviceModel.Image = ms.ToArray();
                        }
                    }
                }
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
开发者ID:garysharp,项目名称:Disco,代码行数:31,代码来源:DeviceDataStoreExtensions.cs

示例2: TestResizeImageToMaximumDimension

        public void TestResizeImageToMaximumDimension()
        {
            using (var image = new Bitmap(ImageLocation))
            {
                var resizedImage = image.ResizeImage(90);

                Assert.AreEqual(90, resizedImage.Width);

                resizedImage.Dispose();
            }
        }
开发者ID:comsechq,项目名称:sugar,代码行数:11,代码来源:BitmapExtensionsTest.cs

示例3: TestResizeImage

        public void TestResizeImage()
        {
            using (var image = new Bitmap(ImageLocation))
            {
                var resizedImage = image.ResizeImage(320, 200);

                Assert.AreEqual(320, resizedImage.Width);
                Assert.AreEqual(200, resizedImage.Height);

                resizedImage.Dispose();
            }
        }
开发者ID:comsechq,项目名称:sugar,代码行数:12,代码来源:BitmapExtensionsTest.cs

示例4: ResizeImage

 public static byte[] ResizeImage(this byte[] imageBytes, int width, int height)
 {
     try
     {
         using (MemoryStream streamInput = new MemoryStream(imageBytes))
         {
             System.Drawing.Image image = new Bitmap(streamInput);
             ImageFormat oldFormat = image.RawFormat;
             image = image.ResizeImage(width, height);
             byte[] result = image.GetBytes(oldFormat);
             return result;
         }
     }
     catch (Exception ex)
     {
         return imageBytes;
     }
 }
开发者ID:jakforest,项目名称:WCFImage,代码行数:18,代码来源:ImageHelper.cs

示例5: Image

 public ActionResult Image(string imageFile, int? width, int? height, int? id)
 {
     var memoryStream = new MemoryStream();
     var image = new Bitmap(ObjectsRepository.CatalogFolder + imageFile.Replace("___", "/"));
     if (width != null && height != null)
     {
         image = image.Clip10X15();
         image = image.ResizeImage(width.Value, height.Value);
     }
     if (id != null)
     {
         image = image.AddBluredRect(30);
         var htmlText = ObjectsRepository.GetObjectDescription(id.Value);
         if (!string.IsNullOrEmpty(htmlText))
         {
             image = image.AddText(30, 0, htmlText);
         }
         //var backImage = new Bitmap(Server.MapPath("~\\Content\\images\\keyend.png"));
         //image = image.AddBackBitmap(backImage);
     }
     image.Save(memoryStream, ImageFormat.Jpeg);
     memoryStream.Seek(0, SeekOrigin.Begin);
     return File(memoryStream, "image/jpeg");
 }
开发者ID:SergeyMironchuk,项目名称:Agentstvo,代码行数:24,代码来源:HomeController.cs

示例6: PasteScaledBitmapImageToTileByLatLon

        void PasteScaledBitmapImageToTileByLatLon(int zoom, double Lon, double Lat, int xTile, int yTile, double scale, Bitmap iconImage)
        {
            int width = iconImage.Width;
            int height = iconImage.Height;
            if (scale != 1.0)
            {
                width = (int)(width * scale);
                height = (int)(height * scale);

            }
            CopyRegionIntoImage(iconImage.ResizeImage((width), (height )), new Rectangle(0, 0, width, height), GetTargetBound(zoom, Lon, Lat, xTile, yTile, width, height));
        }
开发者ID:MoonDav,项目名称:TileRendering,代码行数:12,代码来源:Icon2TileRendering.cs

示例7: PasteIcon

        void PasteIcon(Bitmap icon, int x, int y, double scale)
        {
            int width = icon.Width;
            int height = icon.Height;
            if (scale != 1.0)
            {
                icon.ResizeImage((int)(width * scale), (int)(height * scale));
                width = (int)(width * scale);
                height = (int)(height * scale);
            }

            CopyRegionIntoImage(icon, new Rectangle(0, 0, width, height),  new Rectangle(x, y, width, width));
        }
开发者ID:MoonDav,项目名称:TileRendering,代码行数:13,代码来源:Icon2TileRendering.cs

示例8: LoadExternalMugshots

        /// <summary>
        /// Load all external mugshots into the cache.
        /// </summary>
        private static void LoadExternalMugshots()
        {
            string mugshotFolder = Path.Combine(CIX.HomeFolder, "Mugshots");
            if (Directory.Exists(mugshotFolder))
            {
                string[] allFiles = Directory.GetFiles(mugshotFolder);
                foreach (string filename in allFiles)
                {
                    try
                    {
                        string username = Path.GetFileNameWithoutExtension(filename);
                        Image mugshotImage = new Bitmap(filename);
                        mugshotImage = mugshotImage.ResizeImage(MaxMugshotWidth, MaxMugshotHeight);

                        if (username != null && mugshotImage != null)
                        {
                            Mugshot mugshot = new Mugshot();

                            ImageConverter converter = new ImageConverter();
                            mugshot.Image = (byte[])converter.ConvertTo(mugshotImage, typeof(byte[]));
                            mugshot.Username = username;

                            Cache[username] = mugshot;
                        }
                    }
                    catch (Exception e)
                    {
                        LogFile.WriteLine("Error loading {0} : {1}", filename, e.Message);
                    }
                }
            }
        }
开发者ID:cixonline,项目名称:cixreader,代码行数:35,代码来源:Mugshot.cs


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