• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MagickWand类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Process

        public void Process(MagickWand wand, double percent)
        {
            var currentImage = wand.CurrentImage;
            var height = currentImage.Height;

            using (var draw = new DrawingWand())
            {
                using (PixelWand pixel = new PixelWand())
                {
                    var endX = currentImage.Width - 1;
                    var endY = height - 1;

                    pixel.Color = "black";
                    pixel.Opacity = 0.4;
                    draw.FillColor = pixel;
                    draw.DrawRectangle(0, endY - IndicatorHeight, endX, endY);

                    double foregroundWidth = endX;
                    foregroundWidth *= percent;
                    foregroundWidth /= 100;

                    pixel.Color = "#52B54B";
                    pixel.Opacity = 0;
                    draw.FillColor = pixel;
                    draw.DrawRectangle(0, endY - IndicatorHeight, Convert.ToInt32(Math.Round(foregroundWidth)), endY);
                    wand.CurrentImage.DrawImage(draw);
                }
            }
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:29,代码来源:PercentPlayedDrawer.cs


示例2: SigmoidalTest

 public void SigmoidalTest()
 {
     double[] alpha = { 1, 2, 3, 4 };
     double[] beta = { 0 , 5000, 20000, 30000, 40000, 65000 };
     
     MagickWandEnvironment.Genesis();
     
     foreach(var file in _files)
     {
         using(var wand = new MagickWand(file))
         {
             foreach(var a in alpha)
             {
                 foreach(var b in beta)
                 {
                     using(var tmp = wand.Clone())
                     {
                         tmp.SigmoidalContrastImage(true, a, b);
                         
                         WriteImage("sigmoidal", file, new string[] { a.ToString(), b.ToString() }, tmp);
                     }
                 }
             }
         }
     }
     
     MagickWandEnvironment.Terminus();
 }
开发者ID:AerisG222,项目名称:NMagickWand,代码行数:28,代码来源:ContrastTests.cs


示例3: ProcessPhotoAsync

        public async Task<ProcessingResult> ProcessPhotoAsync(string filename)
        {
            using(var wand = new MagickWand())
            {
                var srcFile = _pathHelper.GetSourceFilePath(filename);

                if(_rawConverter.IsRawFile(srcFile))
                {
                    var conversionResult = await _rawConverter.ConvertAsync(srcFile);
                    
                    wand.ReadImage(conversionResult.OutputFile);
                    File.Delete(conversionResult.OutputFile);
                } 
                else 
                {
                    wand.ReadImage(srcFile);
                }
                
                wand.AutoOrientImage();
                wand.AutoLevelImage();
                wand.StripImage();
                
                var path = Path.Combine(Path.GetDirectoryName(srcFile), "review", $"{Path.GetFileNameWithoutExtension(filename)}.jpg");

                wand.WriteImage(path, true);
            }
            
            return null;
        }
开发者ID:AerisG222,项目名称:SizePhotos,代码行数:29,代码来源:FastReviewPhotoProcessor.cs


示例4: ContrastTest

 public void ContrastTest()
 {
     double[] alpha = { 0, .5, 1, 1.1 };
     double[] beta = { 0 , 5000, 20000, 30000, 40000, 65000 };
     
     MagickWandEnvironment.Genesis();
     
     foreach(var file in _files)
     {
         using(var wand = new MagickWand(file))
         {
             using(var tmp = wand.Clone())
             {
                 tmp.ContrastImage(true);
                 
                 WriteImage("contrast", file, new string[] { "1" }, tmp);
                 
                 tmp.ContrastImage(true);
                 
                 WriteImage("contrast", file, new string[] { "2" }, tmp);
                 
                 tmp.ContrastImage(true);
                 
                 WriteImage("contrast", file, new string[] { "3" }, tmp);
             }
         }
     }
     
     MagickWandEnvironment.Terminus();
 }
开发者ID:AerisG222,项目名称:NMagickWand,代码行数:30,代码来源:ContrastTests.cs


示例5: DrawPlayedIndicator

        public async Task DrawPlayedIndicator(MagickWand wand, ImageSize imageSize)
        {
            var x = imageSize.Width - OffsetFromTopRightCorner;

            using (var draw = new DrawingWand())
            {
                using (PixelWand pixel = new PixelWand())
                {
                    pixel.Color = "#52B54B";
                    pixel.Opacity = 0.2;
                    draw.FillColor = pixel;
                    draw.DrawCircle(x, OffsetFromTopRightCorner, x - 20, OffsetFromTopRightCorner - 20);

                    pixel.Opacity = 0;
                    pixel.Color = "white";
                    draw.FillColor = pixel;
                    draw.Font = await DownloadFont("webdings.ttf", "https://github.com/MediaBrowser/Emby.Resources/raw/master/fonts/webdings.ttf", _appPaths, _iHttpClient, _fileSystem).ConfigureAwait(false);
                    draw.FontSize = FontSize;
                    draw.FontStyle = FontStyleType.NormalStyle;
                    draw.TextAlignment = TextAlignType.CenterAlign;
                    draw.FontWeight = FontWeightType.RegularStyle;
                    draw.TextAntialias = true;
                    draw.DrawAnnotation(x + 4, OffsetFromTopRightCorner + 14, "a");

                    draw.FillColor = pixel;
                    wand.CurrentImage.DrawImage(draw);
                }
            }
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:29,代码来源:PlayedIndicatorDrawer.cs


示例6: Resize

        public void Resize()
        {
            var file = "test3.jpg";

            MagickWandEnvironment.Genesis();

            using(var mw = new MagickWand())
            {
                mw.ReadImage("test.jpg");
                mw.ResizeImage(120, 100, FilterTypes.LanczosFilter, 1);
                mw.WriteImage(file, true);

                Assert.True(File.Exists(file), "scaled image not created");
            }

            using(var mw = new MagickWand(file))
            {
                Assert.True(mw.ImageWidth == 120, "width does not match the expected size");
                Assert.True(mw.ImageHeight == 100, "height does not match the expected size");
            }

            File.Delete(file);

            MagickWandEnvironment.Terminus();
        }
开发者ID:AerisG222,项目名称:NMagickWand,代码行数:25,代码来源:WrapperTests.cs


示例7: GetFontTest

 public void GetFontTest()
 {
     using (var wand = new MagickWand())
     {
         //wand.SetFont("Arial");
         //Debug.WriteLine(wand.GetFont());
     }
 }
开发者ID:NazioByte,项目名称:ImageMagickSharp,代码行数:8,代码来源:MagickWandTests.cs


示例8: CoverArtWandRotateTests

 public void CoverArtWandRotateTests()
 {
     using (var wand = new MagickWand(this.TestImageFolder1))
     {
         wand.CurrentImage.RotateImage(new PixelWand("transparent", 1), 30);
         //wand.CurrentImage.TrimImage(10);
         wand.SaveImage(Path.Combine(SaveDirectory, "logo_extent.png"));
     }
 }
开发者ID:NazioByte,项目名称:ImageMagickSharp,代码行数:9,代码来源:CoverArtWandTests.cs


示例9: MediaBrowserCollectionImageTest

 public void MediaBrowserCollectionImageTest()
 {
     string imageOut = "TestCollectionImages.png";
     using (var wandImages = new MagickWand(TestImageFolder1, TestImageFolder2, TestImageFolder3, TestImageFolder4, TestImageFolder1, TestImageFolder2, TestImageFolder3, TestImageFolder4))
     {
         var wandReturn = MediaBrowserWandExtension.MediaBrowserCollectionImage(wandImages);
         wandReturn.SaveImage(Path.Combine(SaveDirectory, imageOut));
     }
 }
开发者ID:NazioByte,项目名称:ImageMagickSharp,代码行数:9,代码来源:ImageWandTests.cs


示例10: SaveResizedImage

 public void SaveResizedImage(int newWidth, string outPath)
 {
     CreateDirectoryForFile(outPath);
      using (MagickWand wand = new MagickWand()) {
         wand.ReadImage(filename);
         wand.TransformImage("", newWidth.ToString());
         wand.WriteImage (outPath);
     }
 }
开发者ID:codebutler,项目名称:quickthumbs,代码行数:9,代码来源:Image.cs


示例11: Image

        public Image(string filename)
        {
            this.filename = filename;

            using (MagickWand wand = new MagickWand()) {
                wand.ReadImage(filename);
                this.width = (int)wand.ImageWidth;
                this.height = (int)wand.ImageHeight;
            }
        }
开发者ID:codebutler,项目名称:quickthumbs,代码行数:10,代码来源:Image.cs


示例12: ProcessPhotoAsync

 public async Task<ProcessingResult> ProcessPhotoAsync(string filename)
 {
     var result = new ProcessingResult();
     var jpgName = Path.ChangeExtension(filename, ".jpg");
     var origPath = _pathHelper.GetSourceFilePath(filename);
     var srcPath = _pathHelper.GetScaledLocalPath(SourceTarget.ScaledPathSegment, filename);
     
     result.ExifData = await _exifReader.ReadExifDataAsync(origPath);
     
     // always keep the original in the source dir
     File.Move(origPath, srcPath);
     result.Source = new ProcessedPhoto { 
         Target = SourceTarget, 
         LocalFilePath = srcPath, 
         WebFilePath = _pathHelper.GetScaledWebFilePath(SourceTarget.ScaledPathSegment, filename)
     };
     
     using(var wand = new MagickWand())
     {
         if(_rawConverter.IsRawFile(srcPath))
         {
             result.RawConversionResult = await _rawConverter.ConvertAsync(srcPath);
             
             wand.ReadImage(result.RawConversionResult.OutputFile);
             File.Delete(result.RawConversionResult.OutputFile);
         } 
         else 
         {
             wand.ReadImage(srcPath);
         }
         
         result.Source.Height = wand.ImageHeight;
         result.Source.Width = wand.ImageWidth;
         
         wand.AutoOrientImage();
         wand.StripImage();
         
         using(var optWand = wand.Clone())
         {
             result.OptimizationResult = _optimizer.Optimize(optWand);
             
             // get the best compression quality for the optimized image
             // (best => smallest size for negligible quality loss)
             result.CompressionQuality = (short)_qualitySearcher.GetOptimalQuality(optWand);
             
             result.Xs = ProcessTarget(wand, optWand, result.CompressionQuality, XsTarget, jpgName);
             result.Sm = ProcessTarget(wand, optWand, result.CompressionQuality, SmTarget, jpgName);
             result.Md = ProcessTarget(wand, optWand, result.CompressionQuality, MdTarget, jpgName);
             result.Lg = ProcessTarget(wand, optWand, result.CompressionQuality, LgTarget, jpgName);
             result.Print = ProcessTarget(wand, optWand, result.CompressionQuality, PrintTarget, jpgName);
         }
     }
     
     return result;
 }
开发者ID:AerisG222,项目名称:SizePhotos,代码行数:55,代码来源:PhotoProcessor.cs


示例13: ImageWandImageListTest

 public void ImageWandImageListTest()
 {
     using (var wand = new MagickWand(this.TestImageLogo, this.TestImageThumb, this.TestImageBackdrop, this.TestImageFolder1, this.TestImageFolder2, this.TestImageFolder3, this.TestImageFolder4))
     {
         foreach (ImageWand imageWand in wand.ImageList)
         {
             imageWand.RotateImage(new PixelWand("", 1), 45);
             imageWand.TrimImage(100);
         }
         wand.SaveImages(Path.Combine(SaveDirectory, "ListOutput.png"));
     }
 }
开发者ID:NazioByte,项目名称:ImageMagickSharp,代码行数:12,代码来源:MagickWandTests.cs


示例14: DrawUnplayedCountIndicator

        public void DrawUnplayedCountIndicator(MagickWand wand, ImageSize imageSize, int count)
        {
            var x = imageSize.Width - OffsetFromTopRightCorner;
            var text = count.ToString(CultureInfo.InvariantCulture);

            using (var draw = new DrawingWand())
            {
                using (PixelWand pixel = new PixelWand())
                {
                    pixel.Color = "#52B54B";
                    pixel.Opacity = 0.2;
                    draw.FillColor = pixel;
                    draw.DrawCircle(x, OffsetFromTopRightCorner, x - 20, OffsetFromTopRightCorner - 20);

                    pixel.Opacity = 0;
                    pixel.Color = "white";
                    draw.FillColor = pixel;
                    draw.Font = PlayedIndicatorDrawer.ExtractFont("robotoregular.ttf", _appPaths, _fileSystem);
                    draw.FontStyle = FontStyleType.NormalStyle;
                    draw.TextAlignment = TextAlignType.CenterAlign;
                    draw.FontWeight = FontWeightType.RegularStyle;
                    draw.TextAntialias = true;

                    var fontSize = 30;
                    var y = OffsetFromTopRightCorner + 11;

                    if (text.Length == 1)
                    {
                        x += 1;
                    }
                    else if (text.Length == 2)
                    {
                        x += 1;
                    }
                    else if (text.Length >= 3)
                    {
                        //x += 1;
                        y -= 2;
                        fontSize = 24;
                    }

                    draw.FontSize = fontSize;
                    draw.DrawAnnotation(x, y, text);

                    draw.FillColor = pixel;
                    wand.CurrentImage.DrawImage(draw);
                }

            }
        }
开发者ID:paul-777,项目名称:Emby,代码行数:50,代码来源:UnplayedCountIndicator.cs


示例15: CoverArtWandShadowTests

 public void CoverArtWandShadowTests()
 {
     using (var wand = new MagickWand(TestImageFolder1))
     {
         using (MagickWand nailclone = wand.CloneMagickWand())
         using (var blackPixelWand = new PixelWand(ColorName.Black))
         {
             nailclone.CurrentImage.BackgroundColor = blackPixelWand;
             nailclone.CurrentImage.ShadowImage(80, 5, 5, 5);
             nailclone.CurrentImage.CompositeImage(wand, CompositeOperator.CopyCompositeOp, 0, 0);
             nailclone.SaveImage(Path.Combine(SaveDirectory, "logo_extent.png"));
         }
     }
 }
开发者ID:NazioByte,项目名称:ImageMagickSharp,代码行数:14,代码来源:CoverArtWandTests.cs


示例16: MediaBrowserClipMaskTest

        public void MediaBrowserClipMaskTest()
        {
            var dest = new MagickWand(100, 100);
            var mask = new MagickWand();
            var src = new MagickWand(100, 100);

            dest.OpenImage(this.TestImageFolder1);
            mask.OpenImage(this.TestImageFolder2);
            mask.CurrentImage.NegateImage(false);
            mask.SaveImage(Path.Combine(SaveDirectory, "TestImageBackdropMask.png"));
            dest.CurrentImage.SetImageClipMask(mask);
            src.OpenImage(this.TestImageBackdrop);
            dest.CurrentImage.CompositeImage(src, CompositeOperator.OverCompositeOp, 0, 0);
            dest.SaveImage(Path.Combine(SaveDirectory, "TestImageBackdrop.png"));
        }
开发者ID:NazioByte,项目名称:ImageMagickSharp,代码行数:15,代码来源:MediaBrowserWandTests.cs


示例17: CoverArtWand3DTests

        public void CoverArtWand3DTests()
        {
            using (var wand = new MagickWand(TestImageFolder1))
            {
                var t = wand.CloneMagickWand();
                t.CurrentImage.ShearImage(new PixelWand(ColorHEX.None, 1), 0, 10);
                t.CurrentImage.ExtentImage(t.CurrentImage.Width + 50, t.CurrentImage.Height + 50, -25, -25);
                //RaiseImage
                //wand.CurrentImage.ShadeImage(true, 5, 6);
                //
                wand.CurrentImage.TrimImage(100);
                t.SaveImage(Path.Combine(SaveDirectory, "logo_extent.png"));

            }
        }
开发者ID:NazioByte,项目名称:ImageMagickSharp,代码行数:15,代码来源:CoverArtWandTests.cs


示例18: MagickGetImageBitmap

        /// <summary>
        /// Gets a System.Drawing.Bitmap from an ImageMagick wand.
        /// </summary>
        /// <param name="wand"></param>
        /// <returns></returns>
        public static System.Drawing.Bitmap MagickGetImageBitmap(MagickWand wand)
        {
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(
                (int)MagickGetImageWidth(wand), (int)MagickGetImageHeight(wand));

            System.Drawing.Imaging.BitmapData bmpdat = bmp.LockBits(
                new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height),
                System.Drawing.Imaging.ImageLockMode.ReadOnly,
                System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            MagickExportImagePixels(wand, 0, 0, MagickGetImageWidth(wand), MagickGetImageHeight(wand),
                "ARGB", StorageType.CharPixel, bmpdat.Scan0);

            return bmp;
        }
开发者ID:corngood,项目名称:magicksharp,代码行数:20,代码来源:MagickWandImage.cs


示例19: ImageSizeTest

        public void ImageSizeTest()
        {
            var path = TestImageLogo;

            Assert.IsTrue(File.Exists(path));

            using (var wand = new MagickWand(path))
            {
                Debug.WriteLine(wand.CurrentImage.Height);
            }

            using (var wand2 = new MagickWand())
            {
                Assert.IsTrue(wand2.OpenImage(path));
            }
        }
开发者ID:NazioByte,项目名称:ImageMagickSharp,代码行数:16,代码来源:MagickWandTests.cs


示例20: RoundCorners

        /// <summary> Round corners. </summary>
        /// <param name="wand"> The wand to act on. </param>
        /// <param name="cofactor"> The cofactor. </param>
        /// <returns> A MagickWand. </returns>
        public static MagickWand RoundCorners(this MagickWand wand, Double cofactor)
        {
            var currentWidth = wand.CurrentImage.Width;
            var currentHeight = wand.CurrentImage.Height;

            var newWand = new MagickWand(currentWidth, currentHeight, new PixelWand(ColorName.None, 1));

            using (var whitePixelWand = new PixelWand(ColorName.White))
            using (var draw = new DrawingWand(whitePixelWand))
            {
                draw.DrawRoundRectangle(0, 0, currentWidth, currentHeight, cofactor, cofactor);
                newWand.CurrentImage.DrawImage(draw);
                newWand.CurrentImage.CompositeImage(wand, CompositeOperator.SrcInCompositeOp, 0, 0);
                return newWand;
            }
        }
开发者ID:NazioByte,项目名称:ImageMagickSharp,代码行数:20,代码来源:MediaBrowserWandExtension.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Maid类代码示例发布时间:2022-05-24
下一篇:
C# MagickImage类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap