ImageMagick庫的一個.Net封裝: Magick.NET
Magick.NET是ImageMagick庫的一個.Net封裝。ImageMagick 是一個強大的圖片操作庫,支持超過 100 種的文件格式(不包括子格式)。利用 Magick.NET 可以讓你在C#/VB.NET應用中使用 ImageMagick ,而無需在系統中單獨安裝 ImageMagick。
要求
- Visual C++ Redistributable for Visual Studio
- .NET 4.0: Visual C++ Redistributable for Visual Studio 2012 (x86 or x64)
- .NET 2.0: Visual C++ Redistributable for Visual Studio 2008 (x86 orx64) </ul> </li> </ul>
示例代碼:
// Read first frame of gif image using (MagickImage image = new MagickImage("Snakeware.gif")) { // Save frame as jpg image.Write("Snakeware.jpg"); } // Write to stream MagickReadSettings settings = new MagickReadSettings(); // Tells the xc: reader the image to create should be 800x600 settings.Width = 800; settings.Height = 600; using (MemoryStream memStream = new MemoryStream()) { // Create image that is completely purple and 800x600 using (MagickImage image = new MagickImage("xc:purple", settings)) { // Sets the output format to png image.Format = MagickFormat.Png; // Write the image to the memorystream image.Write(memStream); } } // Read image from file using (MagickImage image = new MagickImage("Snakeware.png")) { // Sets the output format to jpeg image.Format = MagickFormat.Jpeg; // Create byte array that contains a jpeg file byte[] data = image.ToByteArray(); }
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!