Beispiel #1
0
 public string Execute(FileItem item, string infile, string dest, ValuePairEnumerator configData)
 {
     var conf = new EffectViewModel(configData);
     dest = Path.Combine(Path.GetDirectoryName(dest), Path.GetFileNameWithoutExtension(dest) + ".jpg");
     using (MagickImage image = new MagickImage(infile))
     {
         switch (conf.SelectedMode)
         {
             case 0:
                 image.SepiaTone(new Percentage(conf.Param1));
                 break;
             case 1:
                 image.OilPaint(conf.Param1,0.1);
                 break;
             case 2:
                 image.Sketch();
                 break;
             case 3:
                 image.Charcoal();
                 break;
             case 4:
                 image.Solarize();
                 break;
             case 5:
                 image.Swirl(conf.Param1);
                 break;
             case 6:
                 image.Wave(PixelInterpolateMethod.Bilinear, conf.Param1, conf.Param2);
                 break;
             case 7:
                 image.BlueShift();
                 break;
             case 8:
                 image.RotationalBlur(conf.Param1);
                 break;
             case 9:
                 image.Raise(conf.Param1);
                 break;
             case 10:
                 image.Negate();
                 break;
             case 11:
                 image.ColorSpace = ColorSpace.Gray;
                 break;
         }
         image.Format = MagickFormat.Jpeg;
         image.Write(dest);
     }
     return dest;
 }
Beispiel #2
0
 private void ExecuteSolarize(XmlElement element, MagickImage image)
 {
   Hashtable arguments = new Hashtable();
   foreach (XmlAttribute attribute in element.Attributes)
   {
     if (attribute.Name == "factor")
       arguments["factor"] = Variables.GetValue<double>(attribute);
     else if (attribute.Name == "factorPercentage")
       arguments["factorPercentage"] = Variables.GetValue<Percentage>(attribute);
   }
   if (arguments.Count == 0)
     image.Solarize();
   else if (OnlyContains(arguments, "factor"))
     image.Solarize((double)arguments["factor"]);
   else if (OnlyContains(arguments, "factorPercentage"))
     image.Solarize((Percentage)arguments["factorPercentage"]);
   else
     throw new ArgumentException("Invalid argument combination for 'solarize', allowed combinations are: [] [factor] [factorPercentage]");
 }
    public void Test_Solarize()
    {
      using (MagickImage image = new MagickImage(Files.Builtin.Logo))
      {
        image.Solarize();

        ColorAssert.AreEqual(MagickColors.Black, image, 125, 125);
        ColorAssert.AreEqual(new MagickColor("#007f7f"), image, 122, 143);
        ColorAssert.AreEqual(new MagickColor("#2e6935"), image, 435, 240);
      }
    }