本文整理汇总了C#中ImageMagick.MagickImage.Ping方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImage.Ping方法的具体用法?C# MagickImage.Ping怎么用?C# MagickImage.Ping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageMagick.MagickImage
的用法示例。
在下文中一共展示了MagickImage.Ping方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Dimensions
public void Test_Dimensions()
{
using (MagickImage image = new MagickImage())
{
MagickReadSettings settings = new MagickReadSettings();
settings.Width = 100;
image.Read(Files.Logos.MagickNETSVG, settings);
Assert.AreEqual(100, image.Width);
Assert.AreEqual(48, image.Height);
settings.Width = null;
settings.Height = 200;
image.Read(Files.Logos.MagickNETSVG, settings);
Assert.AreEqual(415, image.Width);
Assert.AreEqual(200, image.Height);
settings.Width = 300;
settings.Height = 300;
image.Read(Files.Logos.MagickNETSVG, settings);
Assert.AreEqual(300, image.Width);
Assert.AreEqual(144, image.Height);
image.Ping(Files.Logos.MagickNETSVG, settings);
Assert.AreEqual(300, image.Width);
Assert.AreEqual(144, image.Height);
using (FileStream fs = File.OpenRead(Files.Logos.MagickNETSVG))
{
fs.Seek(55, SeekOrigin.Begin);
ExceptionAssert.Throws<MagickMissingDelegateErrorException>(() =>
{
new MagickImageInfo(fs, settings);
});
fs.Seek(55, SeekOrigin.Begin);
settings.Format = MagickFormat.Svg;
MagickImageInfo info = new MagickImageInfo(fs, settings);
Assert.AreEqual(300, info.Width);
Assert.AreEqual(144, info.Height);
}
}
}
示例2: Test_Ping
public void Test_Ping()
{
using (MagickImage image = new MagickImage())
{
image.Ping(Files.FujiFilmFinePixS1ProJPG);
ExceptionAssert.Throws<InvalidOperationException>(delegate ()
{
image.GetReadOnlyPixels();
});
ImageProfile profile = image.Get8BimProfile();
Assert.IsNotNull(profile);
}
}
示例3: Test_Ping
public void Test_Ping()
{
MagickImage image = new MagickImage();
ExceptionAssert.Throws<ArgumentException>(delegate ()
{
image.Ping(new byte[0]);
});
ExceptionAssert.Throws<ArgumentNullException>(delegate ()
{
image.Ping((byte[])null);
});
ExceptionAssert.Throws<ArgumentNullException>(delegate ()
{
image.Ping((Stream)null);
});
ExceptionAssert.Throws<ArgumentNullException>(delegate ()
{
image.Ping((string)null);
});
ExceptionAssert.Throws<ArgumentException>(delegate ()
{
image.Ping(Files.Missing);
});
image.Ping(Files.FujiFilmFinePixS1ProJPG);
Test_Ping(image);
Assert.AreEqual(600, image.Width);
Assert.AreEqual(400, image.Height);
image.Ping(new FileInfo(Files.FujiFilmFinePixS1ProJPG));
Test_Ping(image);
Assert.AreEqual(600, image.Width);
Assert.AreEqual(400, image.Height);
image.Ping(File.ReadAllBytes(Files.FujiFilmFinePixS1ProJPG));
Test_Ping(image);
Assert.AreEqual(600, image.Width);
Assert.AreEqual(400, image.Height);
image.Read(Files.SnakewarePNG);
Assert.AreEqual(286, image.Width);
Assert.AreEqual(67, image.Height);
using (PixelCollection pixels = image.GetPixels())
{
Assert.AreEqual(38324, pixels.ToArray().Length);
}
image.Dispose();
}