本文整理汇总了C#中ImageMagick.MagickImageCollection类的典型用法代码示例。如果您正苦于以下问题:C# MagickImageCollection类的具体用法?C# MagickImageCollection怎么用?C# MagickImageCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MagickImageCollection类属于ImageMagick命名空间,在下文中一共展示了MagickImageCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateAnimatedGif
public static void CreateAnimatedGif()
{
using (MagickImageCollection collection = new MagickImageCollection())
{
// Add first image and set the animation delay to 100ms
collection.Add(SampleFiles.SnakewarePng);
collection[0].AnimationDelay = 100;
// Add second image, set the animation delay to 100ms and flip the image
collection.Add(SampleFiles.SnakewarePng);
collection[1].AnimationDelay = 100;
collection[1].Flip();
// Optionally reduce colors
QuantizeSettings settings = new QuantizeSettings();
settings.Colors = 256;
collection.Quantize(settings);
// Optionally optimize the images (images should have the same size).
collection.Optimize();
// Save gif
collection.Write(SampleFiles.OutputDirectory + "Snakeware.Animated.gif");
}
}
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:25,代码来源:CombiningImages.cs
示例2: Test_Collection_Read
public void Test_Collection_Read()
{
using (MagickImageCollection collection = new MagickImageCollection())
{
MagickReadSettings settings = new MagickReadSettings();
settings.Density = new Density(150);
collection.Read(Files.RoseSparkleGIF, settings);
Assert.AreEqual(150, collection[0].Density.X);
settings = new MagickReadSettings();
settings.FrameIndex = 1;
collection.Read(Files.RoseSparkleGIF, settings);
Assert.AreEqual(1, collection.Count);
settings = new MagickReadSettings();
settings.FrameIndex = 1;
settings.FrameCount = 2;
collection.Read(Files.RoseSparkleGIF, settings);
Assert.AreEqual(2, collection.Count);
settings = null;
collection.Read(Files.RoseSparkleGIF, settings);
}
}
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:30,代码来源:MagickReadSettingsTests.cs
示例3: Exec
public override void Exec()
{
//var pages = this.Beg;
L.D("executing pdf2img by file({0}),destination format({1})", this.AsSrc, this.AsDstF);
this.Cdl.add();
var tf_base = Path.GetTempFileName();
var tf = tf_base + Path.GetExtension(this.AsSrc);
MagickImageCollection images = new MagickImageCollection();
try
{
File.Copy(this.AsSrc, tf, true);
this.Pdf2imgProc(images, tf, -1, 0);
}
catch (Exception e)
{
L.E(e, "executing pdf2img by file({0}),destination format({1}) fail with error->{2}", tf, this.AsDstF, e.Message);
this.Result.Code = 500;
this.Fails.Add(e);
}
try
{
File.Delete(tf);
File.Delete(tf_base);
}
catch (Exception e)
{
L.W("executing pdf2img on delete temp file({0}) error->{1}", tf, e.Message);
}
this.Cdl.done();
this.Cdl.wait();
images.Dispose();
L.D("executing pdf2img by file({0}),destination format({1}) done with pages({2}),fails({3})", this.AsSrc, this.AsDstF, this.Result.Count, this.Fails.Count);
}
开发者ID:Centny,项目名称:cswf.doc,代码行数:33,代码来源:PdfCov.cs
示例4: Pdf2imgProc
protected virtual int Pdf2imgProc(MagickImageCollection images, String pdf, int idx, int file_c)
{
images.Read(pdf, settings);
int pages = images.Count;
if (pages > this.MaxPage)
{
this.Result.Code = 413;
L.D("executing pdf2img by file({0}),destination format({1}) fail with too large code({2}),count({3})",
this.AsSrc, this.AsDstF, this.Result.Code, this.Result.Count);
return 0;
}
if (idx < 0)
{
this.Total = new int[pages];
this.Done = new int[pages];
Util.set(this.Total, 1);
Util.set(this.Done, 0);
}
else
{
this.Total[idx] = pages;
}
for (var i = 0; i < pages; i++)
{
this.Pdf2imgProc(images[i], idx, i, file_c);
}
return pages;
}
开发者ID:Centny,项目名称:cswf.doc,代码行数:28,代码来源:PdfCov.cs
示例5: Test_Append
public void Test_Append()
{
int width = 70;
int height = 46;
using (MagickImageCollection collection = new MagickImageCollection())
{
ExceptionAssert.Throws<InvalidOperationException>(delegate ()
{
collection.AppendHorizontally();
});
ExceptionAssert.Throws<InvalidOperationException>(delegate ()
{
collection.AppendVertically();
});
collection.Read(Files.RoseSparkleGIF);
Assert.AreEqual(width, collection[0].Width);
Assert.AreEqual(height, collection[0].Height);
using (MagickImage image = collection.AppendHorizontally())
{
Assert.AreEqual(width * 3, image.Width);
Assert.AreEqual(height, image.Height);
}
using (MagickImage image = collection.AppendVertically())
{
Assert.AreEqual(width, image.Width);
Assert.AreEqual(height * 3, image.Height);
}
}
}
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:35,代码来源:MagickImageCollectionTests.cs
示例6: CombineScreenshot
/// <summary>
/// Combines the screenshots into one contiguous screenshot
/// </summary>
/// <param name="files">The files (images) to combine</param>
/// <param name="e">For UX, an output progress message</param>
public static void CombineScreenshot(FileSystemInfo[] files, WaitWindowEventArgs e)
{
string screenshotLocation = Path.Combine(Constants.CacheLocation, "temp.png");
using (MagickImageCollection images = new MagickImageCollection())
{
// Add the first image
var orderedFiles = files.OrderBy(f => f.CreationTime);
foreach (FileSystemInfo file in orderedFiles)
{
MagickImage first = new MagickImage(file.FullName);
e.Window.Message = "Obtaining Snapshots... Please Wait";
images.Add(first);
}
using (MagickImage result = images.AppendVertically())
{
e.Window.Message = "Building Screenshot... Please Wait" + System.Environment.NewLine + "This can take a minute.";
try
{
result.Write(screenshotLocation);
} catch (MagickImageErrorException err)
{
Debug.WriteLine($"Error: {err}");
}
}
}
}
开发者ID:joe-williams-cccu,项目名称:OSIRTv2,代码行数:37,代码来源:ScreenshotHelper.cs
示例7: ConvertPDFTOneImage
public static void ConvertPDFTOneImage()
{
MagickReadSettings settings = new MagickReadSettings();
// Settings the density to 300 dpi will create an image with a better quality
settings.Density = new PointD(300, 300);
using (MagickImageCollection images = new MagickImageCollection())
{
// Add all the pages of the pdf file to the collection
images.Read(SampleFiles.SnakewarePdf, settings);
// Create new image that appends all the pages horizontally
using (MagickImage horizontal = images.AppendHorizontally())
{
// Save result as a png
horizontal.Write(SampleFiles.OutputDirectory + "Snakeware.horizontal.png");
}
// Create new image that appends all the pages horizontally
using (MagickImage vertical = images.AppendVertically())
{
// Save result as a png
vertical.Write(SampleFiles.OutputDirectory + "Snakeware.vertical.png");
}
}
}
开发者ID:levesque,项目名称:Magick.NET,代码行数:26,代码来源:ConvertPDF.cs
示例8: ConfigGA
public override void ConfigGA(GeneticAlgorithm ga)
{
base.ConfigGA(ga);
ga.MutationProbability = 0.4f;
ga.TerminationReached += (sender, args) =>
{
using (var collection = new MagickImageCollection())
{
var files = Directory.GetFiles(m_destFolder, "*.png");
foreach (var image in files)
{
collection.Add(image);
collection[0].AnimationDelay = 100;
}
var settings = new QuantizeSettings();
settings.Colors = 256;
collection.Quantize(settings);
collection.Optimize();
collection.Write(Path.Combine(m_destFolder, "result.gif"));
}
};
}
开发者ID:mahmoud-samy-symbyo,项目名称:GeneticSharp,代码行数:25,代码来源:BitmapEqualitySampleController.cs
示例9: Test_Read
private static void Test_Read(MagickImageCollection collection)
{
Assert.AreEqual(3, collection.Count);
foreach (MagickImage image in collection)
{
Assert.AreEqual(70, image.Width);
Assert.AreEqual(46, image.Height);
}
}
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:9,代码来源:MagickImageCollectionTests.cs
示例10: Test_ToBitmap
public void Test_ToBitmap()
{
using (MagickImageCollection collection = new MagickImageCollection(Files.RoseSparkleGIF))
{
Assert.AreEqual(3, collection.Count);
Bitmap bitmap = collection.ToBitmap();
Assert.IsNotNull(bitmap);
Assert.AreEqual(3, bitmap.GetFrameCount(FrameDimension.Page));
}
}
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:11,代码来源:MagickImageCollectionTests.cs
示例11: WriteAndCheckProfile
private static void WriteAndCheckProfile(MagickImageCollection images, PsdWriteDefines defines, int expectedLength)
{
using (MemoryStream memStream = new MemoryStream())
{
images.Write(memStream, defines);
memStream.Position = 0;
images.Read(memStream);
CheckProfile(images[1], expectedLength);
}
}
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:11,代码来源:PsdWriteDefinesTests.cs
示例12: CreatePallete
private MagickImage CreatePallete()
{
using (MagickImageCollection images = new MagickImageCollection())
{
images.Add(new MagickImage(MagickColors.Red, 1, 1));
images.Add(new MagickImage(MagickColors.Blue, 1, 1));
images.Add(new MagickImage(MagickColors.Green, 1, 1));
return images.AppendHorizontally();
}
}
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:11,代码来源:MagickImageTests.cs
示例13: Test_Ping
private static void Test_Ping(MagickImageCollection collection)
{
Assert.AreEqual(1, collection.Count);
ExceptionAssert.Throws<InvalidOperationException>(delegate ()
{
collection[0].GetPixels();
});
ImageProfile profile = collection[0].Get8BimProfile();
Assert.IsNotNull(profile);
}
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:12,代码来源:MagickImageCollectionTests.cs
示例14: Test_Collection_Exceptions
public void Test_Collection_Exceptions()
{
using (MagickImageCollection collection = new MagickImageCollection())
{
MagickReadSettings settings = new MagickReadSettings();
settings.PixelStorage = new PixelStorageSettings();
ExceptionAssert.Throws<ArgumentException>(delegate ()
{
collection.Read(Files.RoseSparkleGIF, settings);
});
}
}
开发者ID:levesque,项目名称:Magick.NET,代码行数:13,代码来源:PixelStorageSettingsTests.cs
示例15: CreatePDFFromTwoImages
public static void CreatePDFFromTwoImages()
{
using (MagickImageCollection collection = new MagickImageCollection())
{
// Add first page
collection.Add(new MagickImage(SampleFiles.SnakewareJpg));
// Add second page
collection.Add(new MagickImage(SampleFiles.SnakewareJpg));
// Create pdf file with two pages
collection.Write(SampleFiles.OutputDirectory + "Snakeware.pdf");
}
}
开发者ID:levesque,项目名称:Magick.NET,代码行数:13,代码来源:ConvertPDF.cs
示例16: CreateIconFromPngFilesFromSvg
public void CreateIconFromPngFilesFromSvg(IconInfo iconInfo)
{
if (iconInfo.NeedUpdate())
{
using (var imageCollection = new MagickImageCollection())
{
foreach (var iconInfoPngFile in iconInfo.PngFiles)
{
var image = new MagickImage(iconInfoPngFile.FullName);
imageCollection.Add(image);
}
imageCollection.Write(iconInfo.IconFile.FullName);
}
}
}
开发者ID:trondr,项目名称:NMultiTool,代码行数:15,代码来源:ImageMagicProvider.cs
示例17: Convert2Jpeg
public void Convert2Jpeg(bool rotate = false)
{
try
{
MagickReadSettings settings = new MagickReadSettings();
// Settings the density to 300 dpi will create an image with a better quality
settings.Density = new PointD(300, 300);
using (MagickImageCollection images = new MagickImageCollection())
{
// Add all the pages of the pdf file to the collection
images.Read(_pdf.FullName, settings);
if (images.Count > 0 && images[0].Format == MagickFormat.Pdf)
{
_logger.InfoFormat("Handle {0}", _pdf.FullName);
int page = 1;
foreach (MagickImage image in images)
{
var newFileName = GetFilePageName(page) + ".jpg";
// Need page rotation?
if (rotate)
image.Rotate(90.0);
// Write page to file that contains the page number
image.Format = MagickFormat.Jpg;
image.CompressionMethod = CompressionMethod.JPEG;
image.Quality = 75;
image.Write(newFileName);
_logger.InfoFormat("-> {0}", newFileName);
// Writing to a specific format works the same as for a single image
page++;
}
}
}
}
catch (Exception ex)
{
_logger.Error(ex.Message, ex);
}
}
开发者ID:Hinni,项目名称:HinniSolutions.PdfToolkit,代码行数:47,代码来源:Converter.cs
示例18: SplitIco
public int SplitIco(string icoFileName)
{
var fullName = Path.GetFullPath(icoFileName);
var folder = Path.GetDirectoryName(fullName);
var baseName = Path.GetFileNameWithoutExtension(fullName);
using (var imageCollection = new MagickImageCollection())
{
imageCollection.Read(icoFileName);
foreach (var image in imageCollection)
{
var pngFileName = baseName + "-" + image.Height + ".png";
var pngFile = Path.Combine(folder, pngFileName);
image.Write(pngFile);
}
}
return 0;
}
开发者ID:trondr,项目名称:NMultiTool,代码行数:17,代码来源:SplitIcoCommandProvider.cs
示例19: Test_AddRange
public void Test_AddRange()
{
using (MagickImageCollection collection = new MagickImageCollection(Files.RoseSparkleGIF))
{
Assert.AreEqual(3, collection.Count);
collection.AddRange(Files.RoseSparkleGIF);
Assert.AreEqual(6, collection.Count);
collection.AddRange(collection);
Assert.AreEqual(12, collection.Count);
List<MagickImage> images = new List<MagickImage>();
images.Add(new MagickImage("xc:red", 100, 100));
collection.AddRange(images);
Assert.AreEqual(13, collection.Count);
}
}
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:18,代码来源:MagickImageCollectionTests.cs
示例20: ConvertPdfToOneTif
private static void ConvertPdfToOneTif()
{
// Log all events
//MagickNET.SetLogEvents(LogEvents.All | LogEvents.Trace);
// Set the log handler (all threads use the same handler)
//MagickNET.Log += DetailedDebugInformationSamples.MagickNET_Log;
string sampleDocsDirectory = @"E:\projects\ImageProcessing\sampledocs\";
string sampleFile = "sample6.pdf";
try
{
MagickReadSettings settings = new MagickReadSettings();
settings.Density = new PointD(300, 300);
using (MagickImageCollection images = new MagickImageCollection())
{
// Add all the pages of the source file to the collection
images.Read(Path.Combine(sampleDocsDirectory, sampleFile), settings);
//Show page count
Console.WriteLine("page count for {0} {1}", sampleFile, images.Count);
string baseFileName = Path.GetFileNameWithoutExtension(sampleFile);
// Create new image that appends all the pages horizontally
//using (MagickImage vertical = images.AppendVertically())
//{
// vertical.CompressionMethod = CompressionMethod.Group4;
// Console.WriteLine("saving file: {0}", baseFileName + ".tif");
// vertical.Write(sampleDocsDirectory + baseFileName + ".tif");
//}
Console.WriteLine("saving file: {0}", baseFileName + ".tif");
images.Write(sampleDocsDirectory + baseFileName + ".tif");
}
}
catch (Exception ex)
{
Console.WriteLine("ConvertPdfToOneTif {0}", ex.Message);
}
}
开发者ID:dstringvc,项目名称:imageprocessing,代码行数:43,代码来源:Program.cs
注:本文中的ImageMagick.MagickImageCollection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论