本文整理汇总了C#中ImageMagick.MagickImageCollection.First方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImageCollection.First方法的具体用法?C# MagickImageCollection.First怎么用?C# MagickImageCollection.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageMagick.MagickImageCollection
的用法示例。
在下文中一共展示了MagickImageCollection.First方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Reverse
public void Test_Reverse()
{
using (MagickImageCollection collection = new MagickImageCollection(Files.RoseSparkleGIF))
{
MagickImage first = collection.First();
collection.Reverse();
MagickImage last = collection.Last();
Assert.IsTrue(last == first);
}
}
示例2: OnSelectedSourceFileChanged
private async void OnSelectedSourceFileChanged()
{
if (SelectedSourceFile == null ||
!SelectedSourceFile.Exists)
return;
var settings = new MagickReadSettings
{
Density = new Density(150, 150),
FrameIndex = 0,
FrameCount = 1
};
var filename = Path.GetTempFileName();
await Task.Run(() =>
{
try
{
using (var images = new MagickImageCollection())
{
images.Read(SelectedSourceFile, settings);
var image = images.First();
image.Format = MagickFormat.Jpeg;
images.Write(filename);
}
}
catch (Exception ex)
{
Log.Warn("Unable to preview document.", ex);
PreviewImage = null;
PreviewImageFilename = null;
SelectedFilePageCount = 0;
}
try
{
using (var pdfReader = new PdfReader(SelectedSourceFile.FullName))
SelectedFilePageCount = pdfReader.NumberOfPages;
}
catch (Exception ex)
{
Log.Warn("Unable to count pages.", ex);
SelectedFilePageCount = 0;
}
});
try
{
var uri = new Uri(filename);
var bitmap = new BitmapImage(uri);
PreviewImage = bitmap;
PreviewImageFilename = filename;
}
catch (Exception)
{
Log.Warn("Unable to preview selected document.");
try
{
var uri = new Uri("pack://application:,,,/PaperPusher;component/Art/unknown_icon_512.png");
var bitmap = new BitmapImage(uri);
PreviewImage = bitmap;
}
catch (Exception ex)
{
Log.Error("Error showing unknown file icon.", ex);
}
}
}