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


C# MagickImage.ToBitmap方法代码示例

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


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

示例1: Test_ToBitmap

 private static void Test_ToBitmap(MagickImage image, ImageFormat format)
 {
   using (Bitmap bmp = image.ToBitmap(format))
   {
     Assert.AreEqual(format, bmp.RawFormat);
   }
 }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:7,代码来源:MagickImageTests.cs

示例2: FastBlur

        public static BitmapImage FastBlur(BitmapImage image, double percentage)
        {
            MagickImage magick = new MagickImage(ImageUtilities.BitmapImage2Bitmap(image));
            magick.Resize(new Percentage(50.0 / percentage));
            magick.Resize(new Percentage(200 * percentage));

            return magick.ToBitmap().ToBitmapImage();
        }
开发者ID:Tragedian-HLife,项目名称:HLife,代码行数:8,代码来源:ImageUtilities.cs

示例3: Blur

        public static Bitmap Blur(Bitmap image, double blurSize)
        {
            MagickImage magick = new MagickImage(image);
            magick.Blur(0, blurSize);
            image = magick.ToBitmap();

            return image;
        }
开发者ID:Tragedian-HLife,项目名称:HLife,代码行数:8,代码来源:ImageUtilities.cs

示例4: LoadFromFileAsImage

 public static Image LoadFromFileAsImage(string filename, bool wrapping = true) {
     if (wrapping && SafeMagickWrapper != null) {
         return SafeMagickWrapper(() => LoadFromFileAsImage(filename, false)) as Image;
     }
     
     using (var image = new MagickImage(filename)) {
         return image.ToBitmap();
     }
 }
开发者ID:gro-ove,项目名称:actools,代码行数:9,代码来源:ImageUtils.cs

示例5: PointGenerator


//.........这里部分代码省略.........
                        #endregion
                    }
                    //#---------------------------------
                    int opacity = 50;
                    switch (_pixFor)
                    {
                        case PixFormat._null:
                            sp0.Clear();
                            throw new Exception("Tanımsız format") { Source = "" };
                            break;
                        case PixFormat._12x12: //12:36 sn
                            opacity = 50;
                            break;
                        case PixFormat._20x20: //3:10 sn
                            opacity = 50;
                            break;
                        case PixFormat._36x36: //0:50 sn
                            opacity = 50;
                            break;
                        case PixFormat._48x48: //0:27 sn
                            opacity = 50;
                            break;
                        case PixFormat._64x64: //0:15 sn
                            opacity = 50;
                            break;
                        case PixFormat._94x94: //0:08 sn
                            opacity = 50;
                            break;
                    }
                    //string MiniPicturePath = Path.Combine(UserProperty.Data_Path, PixFormat._94x94.ToString());  //eski yükleme şekli
                    string MiniPicturePath = Path.Combine(UserProperty.Data_InstagramPhotos);
                    if (Directory.Exists(MiniPicturePath))
                    {
                        Bitmap btm = imagem.ToBitmap();
                        using (Graphics gr1 = Graphics.FromImage(btm))
                        {
                            //string[] list = Directory.GetFiles(MiniPicturePath, "*" + JPG);
                            //string[] list = new string[0];
                            ///////////////////////////////////////////////////////////////
                            string[] file = Directory.GetFiles(UserProperty.Current_User, UserProperty.UserXmlInfo);

                            if (file.Count() != 1)
                                throw new Exception("Geçersiz kullanıcı bilgileri");

                            XDocument doc = XDocument.Load(file[0]);
                            XElement root = doc.Elements("_" + ImageProperty.GetUserName()).First();
                            XElement InstagramP = root.Elements("InstagramPhotos").FirstOrDefault();
                            XElement[] photos = (from p in InstagramP.Elements() where p.Attribute("useThis").Value.ToLower() == "true" select p).ToArray();
                            //list = new string[photos.Count()];

                            //for (int i = 0; i < photos.Count(); i++)
                            //    list[i] = Path.Combine(MiniPicturePath, photos[i].Value);

                            ///////////////////////////////////////////////////
                            if (photos.Count() == 0)
                                throw new Exception("Bu Formata Uygun Resimler Bulunamadı") { Source = "" };

                            List<ImgSquare> spl2 = new List<ImgSquare>();
                            for (int i = 0; i < photos.Count(); i++)
                            {
                                if (File.Exists(Path.Combine(MiniPicturePath, Path.GetFileName(photos[i].Value))))
                                {
                                    using (MagickImage mini = new MagickImage(Path.Combine(MiniPicturePath, Path.GetFileName(photos[i].Value))))
                                    {
                                        mini.Quality = 100;
                                        if (mini.Width != 94 && mini.Height != 94)
开发者ID:msx752,项目名称:OPALOP-Picture-Mosaic,代码行数:67,代码来源:ImageProperty.cs

示例6: DisplayRezisedImage

        private void DisplayRezisedImage(string file, Actions caseDirectory)
        {
            //put this in a background worker.
            try
            {
                using (MagickImage image = new MagickImage(Path.Combine(Constants.ContainerLocation, Constants.Directories.GetSpecifiedCaseDirectory(caseDirectory), file)))
                {
                    MagickGeometry size = new MagickGeometry(196, 196);
                    size.IgnoreAspectRatio = false;
                    image.Resize(size);
                    this.InvokeIfRequired(() => FilePreviewImage.Image = image.ToBitmap());
                }

          
            }
            catch(Exception e)
            {
                DisplayFileIconWithFileSize(file, caseDirectory);
            }
        }
开发者ID:joe-williams-cccu,项目名称:OSIRTv2,代码行数:20,代码来源:RowDetailsPanel.cs

示例7: ImageGenerate


//.........这里部分代码省略.........
                        do
                        {
                            Thread.Sleep(999);
                        } while (servers._respLocalTest.Status == TaskStatus.WaitingForActivation);

                    }
                    else
                    {
                        do
                        {
                            Thread.Sleep(999);
                        } while (
                        servers._resp1.Status == TaskStatus.WaitingForActivation ||
                        servers._resp2.Status == TaskStatus.WaitingForActivation ||
                        servers._resp3.Status == TaskStatus.WaitingForActivation ||
                        servers._resp4.Status == TaskStatus.WaitingForActivation ||
                        servers._resp5.Status == TaskStatus.WaitingForActivation ||
                        servers._resp6.Status == TaskStatus.WaitingForActivation ||
                        servers._resp7.Status == TaskStatus.WaitingForActivation ||
                        servers._resp8.Status == TaskStatus.WaitingForActivation
                        );
                    }
                    DateTime end = DateTime.Now;
                    string time = TimeSpan.FromTicks(end.Ticks - start.Ticks).ToString();
                    resp.Time = (time.Split(':')[time.Split(':').Length - 2] + ":" + time.Split(':')[time.Split(':').Length - 1]);
                    ///////////////////////////////////////
                    if (UserProperty.ComputerNumber == 1)//local test
                    {
                        byte[] bitmp0 = servers._respLocalTest.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br0 = ImageProperty.stringToRectangle(servers._respLocalTest.Result.Body.ImageGenerateResult.ImagePartInfo);
                        MagickImage img0 = new MagickImage(bitmp0);
                        Bitmap newImg0 = new Bitmap(img0.Width, img0.Height);
                        Graphics grr0 = Graphics.FromImage(newImg0);
                        grr0.DrawImage(img0.ToBitmap(), br0.X, br0.Y);
                        grr0.Dispose();
                        (resp.Data as List<object>).Add(ImageProperty.ImageToBase64(newImg0, System.Drawing.Imaging.ImageFormat.Jpeg));
                    }
                    else
                    {
                        byte[] bitmp1 = servers._resp1.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br1 = ImageProperty.stringToRectangle(servers._resp1.Result.Body.ImageGenerateResult.ImagePartInfo);
                        byte[] bitmp2 = servers._resp2.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br2 = ImageProperty.stringToRectangle(servers._resp2.Result.Body.ImageGenerateResult.ImagePartInfo);
                        byte[] bitmp3 = servers._resp3.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br3 = ImageProperty.stringToRectangle(servers._resp3.Result.Body.ImageGenerateResult.ImagePartInfo);
                        byte[] bitmp4 = servers._resp4.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br4 = ImageProperty.stringToRectangle(servers._resp4.Result.Body.ImageGenerateResult.ImagePartInfo);
                        byte[] bitmp5 = servers._resp5.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br5 = ImageProperty.stringToRectangle(servers._resp5.Result.Body.ImageGenerateResult.ImagePartInfo);
                        byte[] bitmp6 = servers._resp6.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br6 = ImageProperty.stringToRectangle(servers._resp6.Result.Body.ImageGenerateResult.ImagePartInfo);
                        byte[] bitmp7 = servers._resp7.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br7 = ImageProperty.stringToRectangle(servers._resp7.Result.Body.ImageGenerateResult.ImagePartInfo);
                        byte[] bitmp8 = servers._resp8.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br8 = ImageProperty.stringToRectangle(servers._resp8.Result.Body.ImageGenerateResult.ImagePartInfo);

                        servers = null;
                        int newW = 0, newH = 0;
                        if (br1.Width < br1.Height)
                        {
                            newW = br1.Width * UserProperty.ComputerNumber;
                            newH = br1.Height;
                        }
                        else
                        {
                            newW = br1.Width;
开发者ID:msx752,项目名称:OPALOP-Picture-Mosaic,代码行数:67,代码来源:ActionController.cs

示例8: processImgForScanning

        private Bitmap processImgForScanning(Bitmap imgInput)
        {
            using (MemoryStream memstream = new MemoryStream())
            {
                imgInput.Save(memstream, ImageFormat.Tiff);
                MagickImage img = new MagickImage(memstream.ToArray());

                if (sharpen)
                {
                    img.Sharpen((int)sharpenIntX.Value, (int)sharpenIntY.Value, Channels.All);
                }

                if (autoGamma)
                {
                    img.AutoGamma();
                }

                if (enhance)
                {
                    img.Enhance();
                }

                if (contrast)
                {
                    img.Contrast();
                }

                if (autoLevel)
                {
                    img.AutoLevel();
                }

                if (autoOrient)
                {
                    img.AutoOrient();
                }

                if (despeckle)
                {
                    img.Despeckle();
                }

                if (medianFilter)
                {
                    img.MedianFilter((int)medianInt.Value);
                }

                if (unsharpmask)
                {
                    img.Unsharpmask(6.8, 4, 4,0);
                }

                if (wtThreshold)
                {
                    img.LinearStretch((float)0.9, 0.1);
                    //img.WhiteThreshold((int)wtThresInt.Value);
                    //img.ReduceNoise();
                    //img.Grayscale(PixelIntensityMethod.Brightness);
                }

                if (invert)
                {
                    img.Negate();
                }

                return img.ToBitmap();
            }
        }
开发者ID:dynamicdeploy,项目名称:ReceiptOCR,代码行数:68,代码来源:Form1.cs

示例9: pictureBox1_Click

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofdlg = new OpenFileDialog();
            ofdlg.ShowDialog();
            var name = ofdlg.FileName;
            if (name.Length > 0)
            {
                origFile = name;

                Stream imageStreamSource = new FileStream(origFile, FileMode.Open, FileAccess.Read, FileShare.Read);
                using (MemoryStream memstream = new MemoryStream())
                {

                    memstream.SetLength(imageStreamSource.Length);
                    imageStreamSource.Read(memstream.GetBuffer(), 0, (int)imageStreamSource.Length);
                    imageStreamSource.Close();
                    MagickImage img = new MagickImage(memstream.ToArray());
                   // img.Grayscale(PixelIntensityMethod.Average);

                    origImg = img.ToBitmap();

                }

                pictureBox1.BackgroundImageLayout = ImageLayout.Stretch;
                pictureBox1.BackgroundImage = origImg;

            }
            else
            {
                MessageBox.Show("Sorry there was an error getting your ne image\rNow Restore previous image");
                pictureBox1.BackgroundImageLayout = ImageLayout.Stretch;
                pictureBox1.BackgroundImage = origImg;
            }
        }
开发者ID:dynamicdeploy,项目名称:ReceiptOCR,代码行数:34,代码来源:Form1.cs

示例10: Test_ToBitmap

    public void Test_ToBitmap()
    {
      using (MagickImage image = new MagickImage(Color.Red, 10, 10))
      {
        ExceptionAssert.Throws<NotSupportedException>(delegate ()
        {
          image.ToBitmap(ImageFormat.Exif);
        });

        Bitmap bitmap = image.ToBitmap();
        Assert.AreEqual(ImageFormat.MemoryBmp, bitmap.RawFormat);
        ColorAssert.AreEqual(Color.Red, bitmap.GetPixel(0, 0));
        ColorAssert.AreEqual(Color.Red, bitmap.GetPixel(5, 5));
        ColorAssert.AreEqual(Color.Red, bitmap.GetPixel(9, 9));
        bitmap.Dispose();

        Test_ToBitmap(image, ImageFormat.Bmp);
        Test_ToBitmap(image, ImageFormat.Gif);
        Test_ToBitmap(image, ImageFormat.Icon);
        Test_ToBitmap(image, ImageFormat.Jpeg);
        Test_ToBitmap(image, ImageFormat.Png);
        Test_ToBitmap(image, ImageFormat.Tiff);
      }

      using (MagickImage image = new MagickImage(new MagickColor(0, Quantum.Max, Quantum.Max, 0), 10, 10))
      {
        Bitmap bitmap = image.ToBitmap();
        Assert.AreEqual(ImageFormat.MemoryBmp, bitmap.RawFormat);
        Color color = Color.FromArgb(0, 0, 255, 255);
        ColorAssert.AreEqual(color, bitmap.GetPixel(0, 0));
        ColorAssert.AreEqual(color, bitmap.GetPixel(5, 5));
        ColorAssert.AreEqual(color, bitmap.GetPixel(9, 9));
        bitmap.Dispose();
      }
    }
开发者ID:marinehero,项目名称:Magick.NET,代码行数:35,代码来源:MagickImageTests.cs

示例11: UpdateShadowTemplate

 private void UpdateShadowTemplate()
 {
     if (mShadowTemplate != null)
     {
         mShadowTemplate.Dispose();
     }
     Bitmap shadowTemplate = new Bitmap(mThumbWidth + 10, mThumbHeight + 10, PixelFormat.Format32bppArgb);
     shadowTemplate.SetResolution(300,300);
     Graphics graphics = Graphics.FromImage(shadowTemplate);
     SolidBrush brush = new SolidBrush(Color.FromArgb((int)(mOptions.ShadowIntensity * 2.55f), 0, 0, 0));
     graphics.FillRectangle(brush, 5, 5, mThumbWidth, mThumbHeight);
     brush.Dispose();
     MagickImage mahd = new MagickImage(shadowTemplate);
     mahd.Blur();
     mShadowTemplate = mahd.ToBitmap();
     //IFilter filter = new GaussianBlur();
     //mShadowTemplate = filter.Apply(shadowTemplate);
     graphics.Dispose();
     shadowTemplate.Dispose();
 }
开发者ID:kevininspace,项目名称:PhotoContactSheetBackup,代码行数:20,代码来源:Thumbnailer.cs

示例12: PointGenerator


//.........这里部分代码省略.........
                    {
                        case PixFormat._null:
                            sp0.Clear();
                            throw new Exception("Tanımsız format") { Source = "" };
                            break;

                        case PixFormat._12x12:
                            opacity = 50;
                            break;

                        case PixFormat._20x20:
                            opacity = 50;
                            break;

                        case PixFormat._36x36:
                            opacity = 50;
                            break;

                        case PixFormat._48x48:
                            opacity = 50;
                            break;

                        case PixFormat._64x64:
                            opacity = 50;
                            break;

                        case PixFormat._94x94:
                            opacity = 50;
                            break;
                    }
                    string MiniPicturePath = Path.Combine(resources.Data_InstagramPhotos);
                    if (Directory.Exists(MiniPicturePath))
                    {
                        Bitmap btm = imagem.ToBitmap();
                        using (Graphics gr1 = Graphics.FromImage(btm))
                        {
                            ///////////////////////////////////////////////////////////////
                            string[] file = Directory.GetFiles(resources.Current_User, resources.UserXmlInfo);

                            if (file.Count() != 1)
                                throw new Exception("Geçersiz kullanıcı bilgileri");

                            XDocument doc = XDocument.Load(file[0]);
                            XElement root = doc.Elements("_" + resources.UserName).First();
                            XElement InstagramP = root.Elements("InstagramPhotos").FirstOrDefault();
                            XElement[] photos = (from p in InstagramP.Elements() where p.Attribute("useThis").Value.ToLower() == "true" select p).ToArray();
                            ///////////////////////////////////////////////////
                            if (photos.Count() == 0)
                                throw new Exception("Bu Formata Uygun Resimler Bulunamadı") { Source = "" };

                            List<ImgSquare> spl2 = new List<ImgSquare>();
                            for (int i = 0; i < photos.Count(); i++)
                            {
                                if (File.Exists(Path.Combine(MiniPicturePath, Path.GetFileName(photos[i].Value))))
                                {
                                    using (MagickImage mini = new MagickImage(Path.Combine(MiniPicturePath, Path.GetFileName(photos[i].Value))))
                                    {
                                        mini.Quality = 100;
                                        if (mini.Width != 94 && mini.Height != 94)
                                            mini.Resize((int)_pixFor, (int)_pixFor);
                                        spl2.Add(new ImgSquare(mini.ToBitmap()));

                                        mini.Dispose();
                                    }
                                }
                            }
开发者ID:msx752,项目名称:OPALOP-Picture-Mosaic,代码行数:67,代码来源:ImageProperty.cs


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