Exemple #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;
 }
Exemple #2
0
 private void ExecuteBlueShift(XmlElement element, MagickImage image)
 {
   Hashtable arguments = new Hashtable();
   foreach (XmlAttribute attribute in element.Attributes)
   {
     arguments[attribute.Name] = Variables.GetValue<double>(attribute);
   }
   if (arguments.Count == 0)
     image.BlueShift();
   else if (OnlyContains(arguments, "factor"))
     image.BlueShift((double)arguments["factor"]);
   else
     throw new ArgumentException("Invalid argument combination for 'blueShift', allowed combinations are: [] [factor]");
 }
    public void Test_BlueShift()
    {
      using (MagickImage image = new MagickImage(Files.Builtin.Logo))
      {
        ColorAssert.AreNotEqual(MagickColors.White, image, 180, 80);

        image.BlueShift(2);

#if Q16HDRI
        ColorAssert.AreNotEqual(MagickColors.White, image, 180, 80);
        image.Clamp();
#endif

        ColorAssert.AreEqual(MagickColors.White, image, 180, 80);

#if Q8 || Q16
        ColorAssert.AreEqual(new MagickColor("#ac2cb333c848"), image, 350, 265);
#elif Q16HDRI
        ColorAssert.AreEqual(new MagickColor("#ac2cb333c848"), image, 350, 265);
#else
#error Not implemented!
#endif
      }
    }