コード例 #1
1
ファイル: TiffTests.cs プロジェクト: dlemstra/Magick.NET
    public void Test_IptcProfile()
    {
      using (MagickImage input = new MagickImage(Files.MagickNETIconPNG))
      {
        IptcProfile profile = input.GetIptcProfile();
        Assert.IsNull(profile);

        profile = new IptcProfile();
        profile.SetValue(IptcTag.Headline, "Magick.NET");
        profile.SetValue(IptcTag.CopyrightNotice, "Copyright.NET");

        input.AddProfile(profile);

        using (MemoryStream memStream = new MemoryStream())
        {
          input.Format = MagickFormat.Tiff;
          input.Write(memStream);

          memStream.Position = 0;
          using (MagickImage output = new MagickImage(memStream))
          {
            profile = output.GetIptcProfile();
            Assert.IsNotNull(profile);
            TestValue(profile, IptcTag.Headline, "Magick.NET");
            TestValue(profile, IptcTag.CopyrightNotice, "Copyright.NET");
          }
        }
      }
    }
コード例 #2
0
    public void Test_FromIXPathNavigable()
    {
      using (MagickImage image = new MagickImage(Files.InvitationTif))
      {
        XmpProfile profile = image.GetXmpProfile();
        Assert.IsNotNull(profile);

        IXPathNavigable doc = profile.ToIXPathNavigable();

        ExceptionAssert.Throws<ArgumentNullException>(delegate ()
        {
          XmpProfile.FromIXPathNavigable(null);
        });

        XmpProfile newProfile = XmpProfile.FromIXPathNavigable(doc);
        image.AddProfile(newProfile);

        doc = profile.ToIXPathNavigable();
        TestIXPathNavigable(doc);

        profile = image.GetXmpProfile();
        Assert.IsNotNull(profile);

        doc = profile.ToIXPathNavigable();
        TestIXPathNavigable(doc);

        Assert.AreEqual(profile, newProfile);
      }
    }
コード例 #3
0
ファイル: ExifFile.cs プロジェクト: SlidEnergy/PhotoOrganizer
		//public PhotoInfo ReadExif2(string name)
		//{
		//	PhotoInfo info = new PhotoInfo() { FileName = name };

		//	using (MagickImage image = new MagickImage(name))
		//	{
		//		ExifProfile profile = image.GetExifProfile();

		//		ExifValue value = profile.GetValue(ExifTag.DateTimeDigitized);

		//		if (value.Value == null)
		//			throw new Exception("Неудалось считать дату и время файла");

		//		info.DateTimeDigitized = (DateTime)value.Value;

		//		value = profile.GetValue(ExifTag.Model);

		//		info.Model = (string)value.Value;

		//		if (info.Model == null)
		//			info.Model = "Неизвестная модель";

		//	}

		//	return info;
		//}

		public static void WriteExif(PhotoInfo info, int? quality)
        {
			// Для моего телефона не работает метод image.AddProfile. Т.к. для моего телефона дату менять ненадо, то пропускаем.
			if (info.Model.ToUpper().Contains("HUAWEI P7-L10"))
				return;

			using (MagickImage image = new MagickImage(info.FileName))
            {
				if (quality != null && quality < image.Quality)
					image.Quality = quality.Value;

                ExifProfile profile = image.GetExifProfile();

				if (profile == null)
					profile = new ExifProfile();

                profile.SetValue(ExifTag.DateTimeDigitized, info.DateTimeDigitized.ToString(DATE_TIME_FORMAT));
				profile.SetValue(ExifTag.DateTime, info.DateTimeDigitized.ToString(DATE_TIME_FORMAT));
				profile.SetValue(ExifTag.DateTimeOriginal, info.DateTimeDigitized.ToString(DATE_TIME_FORMAT));

				//try
				//{
					image.AddProfile(profile, true);

					image.Write(info.FileName);
				//}
				//catch (Exception exc)
				//{ 
				
				//}
            }
        }
コード例 #4
0
    public void Test_ICM()
    {
      using (MagickImage image = new MagickImage(Files.SnakewarePNG))
      {
        ColorProfile profile = image.GetColorProfile();
        Assert.IsNull(profile);

        image.AddProfile(new ImageProfile("icm", ColorProfile.SRGB.ToByteArray()));
        TestProfile(image.GetColorProfile(), "icm");
      }
    }
コード例 #5
0
    public void Test_Info()
    {
      using (MagickImage image = new MagickImage(Files.MagickNETIconPNG))
      {
        image.AddProfile(ColorProfile.USWebCoatedSWOP);

        Assert.AreEqual("U.S. Web Coated (SWOP) v2", image.GetAttribute("icc:description"));
        Assert.AreEqual("U.S. Web Coated (SWOP) v2", image.GetAttribute("icc:manufacturer"));
        Assert.AreEqual("U.S. Web Coated (SWOP) v2", image.GetAttribute("icc:model"));
        Assert.AreEqual("Copyright 2000 Adobe Systems, Inc.", image.GetAttribute("icc:copyright"));
      }
    }
コード例 #6
0
ファイル: ConvertImage.cs プロジェクト: dlemstra/Magick.NET
    public static void ConvertCmykToRgb()
    {
      // Uses sRGB.icm, eps/pdf produce better result when you set this before loading.
      MagickReadSettings settings = new MagickReadSettings();
      settings.ColorSpace = ColorSpace.sRGB;

      // Create empty image
      using (MagickImage image = new MagickImage())
      {
        // Reads the eps image, the specified settings tell Ghostscript to create an sRGB image
        image.Read(SampleFiles.SnakewareEps, settings);
        // Save image as tiff
        image.Write(SampleFiles.OutputDirectory + "Snakeware.tiff");
      }

      // Read image from file
      using (MagickImage image = new MagickImage(SampleFiles.SnakewareJpg))
      {
        // First add a CMYK profile if your image does not contain a color profile.
        image.AddProfile(ColorProfile.USWebCoatedSWOP);

        // Adding the second profile will transform the colorspace from CMYK to RGB
        image.AddProfile(ColorProfile.SRGB);
        // Save image as png
        image.Write(SampleFiles.OutputDirectory + "Snakeware.png");
      }

      // Read image from file
      using (MagickImage image = new MagickImage(SampleFiles.SnakewareJpg))
      {
        // First add a CMYK profile if your image does not contain a color profile.
        image.AddProfile(ColorProfile.USWebCoatedSWOP);

        // Adding the second profile will transform the colorspace from your custom icc profile
        image.AddProfile(new ColorProfile(SampleFiles.YourProfileIcc));
        // Save image as tiff
        image.Write(SampleFiles.OutputDirectory + "Snakeware.tiff");
      }
    }
コード例 #7
0
    public void Test_ClippingPaths()
    {
      using (MagickImage image = new MagickImage(Files.EightBimTIF))
      {
        EightBimProfile profile = image.Get8BimProfile();
        TestProfile(profile);

        using (MagickImage emptyImage = new MagickImage(Files.EightBimTIF))
        {
          emptyImage.Strip();
          Assert.IsNull(emptyImage.GetIptcProfile());
          emptyImage.AddProfile(profile);

          profile = emptyImage.Get8BimProfile();
          TestProfile(profile);
        }
      }
    }
コード例 #8
0
    public void Test_Fraction()
    {
      using (MemoryStream memStream = new MemoryStream())
      {
        double exposureTime = 1.0 / 1600;

        using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
        {
          ExifProfile profile = image.GetExifProfile();

          profile.SetValue(ExifTag.ExposureTime, exposureTime);
          image.AddProfile(profile);

          image.Write(memStream);
        }

        memStream.Position = 0;
        using (MagickImage image = new MagickImage(memStream))
        {
          ExifProfile profile = image.GetExifProfile();

          Assert.IsNotNull(profile);

          ExifValue value = profile.GetValue(ExifTag.ExposureTime);
          Assert.IsNotNull(value);
          Assert.AreNotEqual(exposureTime, value.Value);
        }

        memStream.Position = 0;
        using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
        {
          ExifProfile profile = image.GetExifProfile();

          profile.SetValue(ExifTag.ExposureTime, exposureTime);
          profile.BestPrecision = true;
          image.AddProfile(profile);

          image.Write(memStream);
        }

        memStream.Position = 0;
        using (MagickImage image = new MagickImage(memStream))
        {
          ExifProfile profile = image.GetExifProfile();

          Assert.IsNotNull(profile);

          ExifValue value = profile.GetValue(ExifTag.ExposureTime);
          TestValue(value, exposureTime);
        }
      }
    }
コード例 #9
0
    public void Test_WithImage()
    {
      using (MagickImage image = new MagickImage())
      {
        image.AddProfile(ColorProfile.USWebCoatedSWOP);
        ExceptionAssert.Throws<MagickCacheErrorException>(delegate ()
        {
          image.ColorSpace = ColorSpace.CMYK;
        });
        image.Read(Files.SnakewarePNG);

        ColorProfile profile = image.GetColorProfile();
        Assert.IsNull(profile);

        image.AddProfile(ColorProfile.SRGB);
        TestProfile(image.GetColorProfile(), "icc");
      }
    }
コード例 #10
0
ファイル: MagickImage.cs プロジェクト: dlemstra/Magick.NET
 private void ExecuteAddProfile(XmlElement element, MagickImage image)
 {
   Hashtable arguments = new Hashtable();
   foreach (XmlAttribute attribute in element.Attributes)
   {
     arguments[attribute.Name] = Variables.GetValue<Boolean>(attribute);
   }
   foreach (XmlElement elem in element.SelectNodes("*"))
   {
     arguments[elem.Name] = CreateProfile(elem);
   }
   if (OnlyContains(arguments, "profile"))
     image.AddProfile((ImageProfile)arguments["profile"]);
   else if (OnlyContains(arguments, "profile", "overwriteExisting"))
     image.AddProfile((ImageProfile)arguments["profile"], (Boolean)arguments["overwriteExisting"]);
   else
     throw new ArgumentException("Invalid argument combination for 'addProfile', allowed combinations are: [profile] [profile, overwriteExisting]");
 }
コード例 #11
0
    public void Test_Values()
    {
      using (MagickImage image = new MagickImage(Files.EightBimTIF))
      {
        EightBimProfile profile = image.Get8BimProfile();
        TestProfileValues(profile);

        using (MagickImage emptyImage = new MagickImage(Files.ImageMagickJPG))
        {
          Assert.IsNull(emptyImage.Get8BimProfile());
          emptyImage.AddProfile(profile);

          profile = emptyImage.Get8BimProfile();
          TestProfileValues(profile);
        }
      }
    }
コード例 #12
0
    public void Test_Constructor()
    {
      using (MemoryStream memStream = new MemoryStream())
      {
        using (MagickImage image = new MagickImage(Files.ImageMagickJPG))
        {
          ExifProfile profile = image.GetExifProfile();
          Assert.IsNull(profile);

          profile = new ExifProfile();
          profile.SetValue(ExifTag.Copyright, "Dirk Lemstra");

          image.AddProfile(profile);

          profile = image.GetExifProfile();
          Assert.IsNotNull(profile);

          image.Write(memStream);
        }

        memStream.Position = 0;
        using (MagickImage image = new MagickImage(memStream))
        {
          ExifProfile profile = image.GetExifProfile();

          Assert.IsNotNull(profile);
          Assert.AreEqual(1, profile.Values.Count());

          ExifValue value = profile.Values.FirstOrDefault(val => val.Tag == ExifTag.Copyright);
          TestValue(value, "Dirk Lemstra");
        }
      }
    }
コード例 #13
0
    public void Test_SetValue()
    {
      double[] latitude = new double[] { 12.3, 4.56, 789.0 };

      using (MemoryStream memStream = new MemoryStream())
      {
        using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
        {
          ExifProfile profile = image.GetExifProfile();
          profile.SetValue(ExifTag.Software, "Magick.NET");

          ExifValue value = profile.GetValue(ExifTag.Software);
          TestValue(value, "Magick.NET");

          ExceptionAssert.Throws<ArgumentException>(delegate ()
          {
            value.Value = 15;
          });

          profile.SetValue(ExifTag.ShutterSpeedValue, 75.55);

          value = profile.GetValue(ExifTag.ShutterSpeedValue);
          TestValue(value, 75.55);

          ExceptionAssert.Throws<ArgumentException>(delegate ()
          {
            value.Value = 75;
          });

          profile.SetValue(ExifTag.XResolution, 150.0);

          value = profile.GetValue(ExifTag.XResolution);
          TestValue(value, 150.0);

          ExceptionAssert.Throws<ArgumentException>(delegate ()
          {
            value.Value = "Magick.NET";
          });

          image.Density = new PointD(72);

          value = profile.GetValue(ExifTag.XResolution);
          TestValue(value, 150.0);

          value = profile.GetValue(ExifTag.ReferenceBlackWhite);
          Assert.IsNotNull(value);

          profile.SetValue(ExifTag.ReferenceBlackWhite, null);

          value = profile.GetValue(ExifTag.ReferenceBlackWhite);
          TestValue(value, (string)null);

          profile.SetValue(ExifTag.GPSLatitude, latitude);

          value = profile.GetValue(ExifTag.GPSLatitude);
          TestValue(value, latitude);

          image.AddProfile(profile);

          image.Write(memStream);
        }

        memStream.Position = 0;
        using (MagickImage image = new MagickImage(memStream))
        {
          ExifProfile profile = image.GetExifProfile();

          Assert.IsNotNull(profile);
          Assert.AreEqual(43, profile.Values.Count());

          ExifValue value = profile.GetValue(ExifTag.Software);
          TestValue(value, "Magick.NET");

          value = profile.GetValue(ExifTag.ShutterSpeedValue);
          TestValue(value, 75.55);

          value = profile.GetValue(ExifTag.XResolution);
          TestValue(value, 72.0);

          value = profile.GetValue(ExifTag.ReferenceBlackWhite);
          Assert.IsNull(value);

          value = profile.GetValue(ExifTag.GPSLatitude);
          TestValue(value, latitude);

          profile.Parts = ExifParts.ExifTags;

          image.AddProfile(profile);

          memStream.Position = 0;
          image.Write(memStream);
        }

        memStream.Position = 0;
        using (MagickImage image = new MagickImage(memStream))
        {
          ExifProfile profile = image.GetExifProfile();

          Assert.IsNotNull(profile);
          Assert.AreEqual(24, profile.Values.Count());

          Assert.IsNotNull(profile.GetValue(ExifTag.FNumber));
          Assert.IsTrue(profile.RemoveValue(ExifTag.FNumber));
          Assert.IsFalse(profile.RemoveValue(ExifTag.FNumber));
          Assert.IsNull(profile.GetValue(ExifTag.FNumber));

          Assert.AreEqual(23, profile.Values.Count());
        }
      }
    }
コード例 #14
0
    public void Test_Values()
    {
      using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
      {
        ExifProfile profile = image.GetExifProfile();
        TestProfile(profile);

        using (MagickImage emptyImage = new MagickImage(Files.ImageMagickJPG))
        {
          Assert.IsNull(emptyImage.GetExifProfile());
          emptyImage.AddProfile(profile);

          profile = emptyImage.GetExifProfile();
          TestProfile(profile);
        }
      }
    }
コード例 #15
0
    public void Test_Infinity()
    {
      using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
      {
        ExifProfile profile = image.GetExifProfile();
        profile.SetValue(ExifTag.ExposureBiasValue, new SignedRational(double.PositiveInfinity));
        image.AddProfile(profile);

        profile = image.GetExifProfile();
        ExifValue value = profile.GetValue(ExifTag.ExposureBiasValue);
        Assert.IsNotNull(value);
        Assert.AreEqual(double.PositiveInfinity, ((SignedRational)value.Value).ToDouble());

        profile.SetValue(ExifTag.ExposureBiasValue, new SignedRational(double.NegativeInfinity));
        image.AddProfile(profile);

        profile = image.GetExifProfile();
        value = profile.GetValue(ExifTag.ExposureBiasValue);
        Assert.IsNotNull(value);
        Assert.AreEqual(double.NegativeInfinity, ((SignedRational)value.Value).ToDouble());

        profile.SetValue(ExifTag.FlashEnergy, new Rational(double.NegativeInfinity));
        image.AddProfile(profile);

        profile = image.GetExifProfile();
        value = profile.GetValue(ExifTag.FlashEnergy);
        Assert.IsNotNull(value);
        Assert.AreEqual(double.PositiveInfinity, ((Rational)value.Value).ToDouble());
      }
    }
コード例 #16
0
    public void Test_Infinity()
    {
      using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
      {
        ExifProfile profile = image.GetExifProfile();
        profile.SetValue(ExifTag.ExposureBiasValue, double.PositiveInfinity);
        image.AddProfile(profile);

        profile = image.GetExifProfile();
        ExifValue value = profile.GetValue(ExifTag.ExposureBiasValue);
        Assert.IsNotNull(value);
        Assert.IsTrue(double.PositiveInfinity.Equals(value.Value));

        profile.SetValue(ExifTag.ExposureBiasValue, double.NegativeInfinity);
        image.AddProfile(profile);

        profile = image.GetExifProfile();
        value = profile.GetValue(ExifTag.ExposureBiasValue);
        Assert.IsNotNull(value);
        Assert.IsTrue(double.NegativeInfinity.Equals(value.Value));

        profile.SetValue(ExifTag.FlashEnergy, double.NegativeInfinity);
        image.AddProfile(profile);

        profile = image.GetExifProfile();
        value = profile.GetValue(ExifTag.FlashEnergy);
        Assert.IsNotNull(value);
        Assert.IsTrue(double.PositiveInfinity.Equals(value.Value));
      }
    }
コード例 #17
0
    public void Test_AutoOrient()
    {
      using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProPNG))
      {
        Assert.AreEqual(600, image.Width);
        Assert.AreEqual(400, image.Height);
        Assert.AreEqual(OrientationType.TopLeft, image.Orientation);

        ExifProfile profile = image.GetExifProfile();
        profile.SetValue(ExifTag.Orientation, (ushort)6);
        image.AddProfile(profile);

        using (MemoryStream memStream = new MemoryStream())
        {
          image.Write(memStream);

          memStream.Position = 0;
          image.Read(memStream);

          Assert.AreEqual(600, image.Width);
          Assert.AreEqual(400, image.Height);
          Assert.AreEqual(OrientationType.RightTop, image.Orientation);

          image.AutoOrient();

          Assert.AreEqual(400, image.Width);
          Assert.AreEqual(600, image.Height);
          Assert.AreEqual(OrientationType.TopLeft, image.Orientation);
        }
      }
    }
コード例 #18
0
    public void Test_AddProfile()
    {
      using (MagickImage image = new MagickImage(Files.SnakewarePNG))
      {
        ColorProfile profile = image.GetColorProfile();
        Assert.IsNull(profile);

        image.AddProfile(ColorProfile.SRGB);
        profile = image.GetColorProfile();
        Assert.IsNotNull(profile);
        Assert.AreEqual(3144, profile.ToByteArray().Length);

        image.AddProfile(ColorProfile.AppleRGB, false);
        profile = image.GetColorProfile();
        Assert.IsNotNull(profile);
        Assert.AreEqual(3144, profile.ToByteArray().Length);

        image.AddProfile(ColorProfile.AppleRGB);
        profile = image.GetColorProfile();
        Assert.IsNotNull(profile);
        Assert.AreEqual(552, profile.ToByteArray().Length);
      }
    }
コード例 #19
0
    public void Test_SetValue()
    {
      using (MemoryStream memStream = new MemoryStream())
      {
        string credit = null;
        for (int i = 0; i < 255; i++)
          credit += i.ToString() + ".";

        using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
        {
          IptcProfile profile = image.GetIptcProfile();
          TestProfileValues(profile);

          IptcValue value = profile.GetValue(IptcTag.Title);
          TestValue(value, "Communications");

          profile.SetValue(IptcTag.Title, "Magick.NET Title");
          TestValue(value, "Magick.NET Title");

          value = profile.GetValue(IptcTag.Title);
          TestValue(value, "Magick.NET Title");

          value = profile.Values.FirstOrDefault(val => val.Tag == IptcTag.ReferenceNumber);
          Assert.IsNull(value);

          profile.SetValue(IptcTag.ReferenceNumber, "Magick.NET ReferenceNümber");

          value = profile.GetValue(IptcTag.ReferenceNumber);
          TestValue(value, "Magick.NET ReferenceNümber");

          profile.SetValue(IptcTag.Credit, credit);

          value = profile.GetValue(IptcTag.Credit);
          TestValue(value, credit);

          // Remove the 8bim profile so we can overwrite the iptc profile.
          image.RemoveProfile("8bim");
          image.AddProfile(profile);

          image.Write(memStream);
          memStream.Position = 0;
        }

        using (MagickImage image = new MagickImage(memStream))
        {
          IptcProfile profile = image.GetIptcProfile();
          TestProfileValues(profile, 19);

          IptcValue value = profile.GetValue(IptcTag.Title);
          TestValue(value, "Magick.NET Title");

          value = profile.GetValue(IptcTag.ReferenceNumber);
          TestValue(value, "Magick.NET ReferenceNümber");

          value = profile.GetValue(IptcTag.Credit);
          TestValue(value, credit);

          ExceptionAssert.Throws<ArgumentNullException>(delegate ()
          {
            profile.SetValue(IptcTag.Caption, null, "Test");
          });

          profile.SetValue(IptcTag.Caption, "Test");
          value = profile.Values.ElementAt(1);
          Assert.AreEqual("Test", value.Value);

          profile.SetValue(IptcTag.Caption, Encoding.UTF32, "Test");
          Assert.AreEqual(Encoding.UTF32, value.Encoding);
          Assert.AreEqual("Test", value.Value);

          Assert.IsTrue(profile.RemoveValue(IptcTag.Caption));
          Assert.IsFalse(profile.RemoveValue(IptcTag.Caption));
          Assert.IsNull(profile.GetValue(IptcTag.Caption));
        }
      }
    }
コード例 #20
0
    public void Test_ToBitmapSource()
    {
      byte[] pixels = new byte[600];

      using (MagickImage image = new MagickImage(Color.Red, 10, 10))
      {
        BitmapSource bitmap = image.ToBitmapSource();
        bitmap.CopyPixels(pixels, 60, 0);

        Assert.AreEqual(255, pixels[0]);
        Assert.AreEqual(0, pixels[1]);
        Assert.AreEqual(0, pixels[2]);

        image.ColorSpace = ColorSpace.CMYK;

        bitmap = image.ToBitmapSource();
        bitmap.CopyPixels(pixels, 60, 0);

        Assert.AreEqual(0, pixels[0]);
        Assert.AreEqual(255, pixels[1]);
        Assert.AreEqual(255, pixels[2]);
        Assert.AreEqual(0, pixels[3]);

        image.AddProfile(ColorProfile.USWebCoatedSWOP);
        image.AddProfile(ColorProfile.SRGB);

        bitmap = image.ToBitmapSource();
        bitmap.CopyPixels(pixels, 60, 0);

        Assert.AreEqual(237, pixels[0]);
        Assert.AreEqual(28, pixels[1]);
        Assert.AreEqual(36, pixels[2]);
      }
    }
コード例 #21
0
    public void Test_ToBitmapSource()
    {
      byte[] pixels = new byte[600];

      using (MagickImage image = new MagickImage(MagickColors.Red, 10, 10))
      {
        BitmapSource bitmap = image.ToBitmapSource();
        Assert.AreEqual(MediaPixelFormats.Rgb24, bitmap.Format);
        bitmap.CopyPixels(pixels, 60, 0);

        Assert.AreEqual(255, pixels[0]);
        Assert.AreEqual(0, pixels[1]);
        Assert.AreEqual(0, pixels[2]);

        image.ColorSpace = ColorSpace.CMYK;

        bitmap = image.ToBitmapSource();
        Assert.AreEqual(MediaPixelFormats.Cmyk32, bitmap.Format);
        bitmap.CopyPixels(pixels, 60, 0);

        Assert.AreEqual(0, pixels[0]);
        Assert.AreEqual(255, pixels[1]);
        Assert.AreEqual(255, pixels[2]);
        Assert.AreEqual(0, pixels[3]);

        image.AddProfile(ColorProfile.USWebCoatedSWOP);
        image.AddProfile(ColorProfile.SRGB);

        bitmap = image.ToBitmapSource();
        Assert.AreEqual(MediaPixelFormats.Rgb24, bitmap.Format);
        bitmap.CopyPixels(pixels, 60, 0);

        Assert.AreEqual(237, pixels[0]);
        Assert.AreEqual(28, pixels[1]);
        Assert.AreEqual(36, pixels[2]);

        image.HasAlpha = true;

        bitmap = image.ToBitmapSource();
        Assert.AreEqual(MediaPixelFormats.Bgra32, bitmap.Format);
        bitmap.CopyPixels(pixels, 60, 0);

        Assert.AreEqual(36, pixels[0]);
        Assert.AreEqual(28, pixels[1]);
        Assert.AreEqual(237, pixels[2]);
        Assert.AreEqual(255, pixels[3]);
      }
    }
コード例 #22
0
    public void Test_Remove()
    {
      using (MagickImage image = new MagickImage(Files.SnakewarePNG))
      {
        ColorProfile profile = image.GetColorProfile();
        Assert.IsNull(profile);

        image.AddProfile(ColorProfile.SRGB);

        Assert.IsNull(image.GetProfile("icm"));

        profile = image.GetColorProfile();
        Assert.IsNotNull(profile);

        image.RemoveProfile(profile.Name);

        profile = image.GetColorProfile();
        Assert.IsNull(profile);
      }
    }
コード例 #23
0
 public void Test_Constructor_Empty()
 {
   using (MagickImage image = new MagickImage(Files.ImageMagickJPG))
   {
     using (MemoryStream memStream = new MemoryStream())
     {
       ExifProfile profile = new ExifProfile(memStream);
       image.AddProfile(profile);
     }
   }
 }