Class for defines that are used when a jpeg image is written.
Inheritance: DefineCreator, IWriteDefines
    public void Test_DctMethod_OptimizeCoding_Quality_QuantizationTables_SamplingFactors()
    {
      JpegWriteDefines defines = new JpegWriteDefines()
      {
        DctMethod = DctMethod.Fast,
        OptimizeCoding = false,
        Quality = new MagickGeometry(80, 80),
        QuantizationTables = @"C:\path\to\file.xml",
        SamplingFactors = new MagickGeometry[]
        {
          new MagickGeometry(5, 10),
          new MagickGeometry(15, 20)
        }
      };

      using (MagickImage image = new MagickImage(Files.Builtin.Logo))
      {
        image.Settings.SetDefines(defines);

        Assert.AreEqual("Fast", image.Settings.GetDefine(MagickFormat.Jpeg, "dct-method"));
        Assert.AreEqual("False", image.Settings.GetDefine(MagickFormat.Jpeg, "optimize-coding"));
        Assert.AreEqual("80x80", image.Settings.GetDefine(MagickFormat.Jpeg, "quality"));
        Assert.AreEqual(@"C:\path\to\file.xml", image.Settings.GetDefine(MagickFormat.Jpeg, "q-table"));
        Assert.AreEqual("5x10,15x20", image.Settings.GetDefine(MagickFormat.Jpeg, "sampling-factor"));
      }
    }
Exemple #2
0
        private IDefines CreateJpegWriteDefines(XmlElement element)
        {
            if (element == null)
            {
                return(null);
            }
            JpegWriteDefines result = new JpegWriteDefines();

            result.ArithmeticCoding   = GetValue <Nullable <Boolean> >(element, "arithmeticCoding");
            result.DctMethod          = GetValue <Nullable <ImageMagick.Defines.DctMethod> >(element, "dctMethod");
            result.Extent             = GetValue <Nullable <Int32> >(element, "extent");
            result.OptimizeCoding     = GetValue <Nullable <Boolean> >(element, "optimizeCoding");
            result.QuantizationTables = GetValue <String>(element, "quantizationTables");
            result.SamplingFactor     = GetValue <Nullable <ImageMagick.Defines.SamplingFactor> >(element, "samplingFactor");
            return(result);
        }
Exemple #3
0
        private IDefines CreateJpegWriteDefines(XmlElement element)
        {
            if (element == null)
            {
                return(null);
            }
            JpegWriteDefines result = new JpegWriteDefines();

            result.DctMethod          = Variables.GetValue <Nullable <ImageMagick.Defines.DctMethod> >(element, "dctMethod");
            result.Extent             = Variables.GetValue <Nullable <Int32> >(element, "extent");
            result.OptimizeCoding     = Variables.GetValue <Nullable <Boolean> >(element, "optimizeCoding");
            result.Quality            = Variables.GetValue <MagickGeometry>(element, "quality");
            result.QuantizationTables = Variables.GetValue <String>(element, "quantizationTables");
            result.SamplingFactors    = CreateMagickGeometryCollection(element);
            return(result);
        }
    public void Test_Extent()
    {
      JpegWriteDefines defines = new JpegWriteDefines()
      {
        Extent = 10
      };

      using (MagickImage image = new MagickImage(Files.Builtin.Logo))
      {
        using (MemoryStream memStream = new MemoryStream())
        {
          image.Settings.SetDefines(defines);

          image.Format = MagickFormat.Jpeg;
          image.Write(memStream);
          Assert.IsTrue(memStream.Length < 10000);
        }
      }
    }
Exemple #5
0
 private IDefines CreateJpegWriteDefines(XmlElement element)
 {
   if (element == null)
     return null;
   JpegWriteDefines result = new JpegWriteDefines();
   result.DctMethod = Variables.GetValue<Nullable<ImageMagick.Defines.DctMethod>>(element, "dctMethod");
   result.Extent = Variables.GetValue<Nullable<Int32>>(element, "extent");
   result.OptimizeCoding = Variables.GetValue<Nullable<Boolean>>(element, "optimizeCoding");
   result.Quality = Variables.GetValue<MagickGeometry>(element, "quality");
   result.QuantizationTables = Variables.GetValue<String>(element, "quantizationTables");
   result.SamplingFactors = CreateMagickGeometryCollection(element);
   return result;
 }