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


C# MagickWand类代码示例

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


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


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