Labview调用 Magick.NET实现图像格式转换
标签搜索
侧边栏壁纸
  • 累计撰写 36 篇文章
  • 累计收到 3 条评论

Labview调用 Magick.NET实现图像格式转换

CloudZ
2022-10-06 / 0 评论 / 16 阅读 / 正在检测是否收录...

ImageMagick

Use ImageMagick to create, edit, compose, or convert digital images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, GIF, WebP, HEIC, SVG, PDF, DPX, EXR and TIFF. ImageMagick can resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves。

https://imagemagick.org/index.php


ImageMagick的 .NET 库: Magick.NET

https://github.com/dlemstra/Magick.NET


使用命令行的labview封装

https://lavag.org/files/file/48-lvoop-imagemagick-interface/

经过实际测试可以直接加载.net版本的DLL无需使用命令行程序,但是转换SVG格式图像的时候会出现SVG显示异常的问题,并且emf文件只支持读取不支持写入,因此改用SVG.NET库,没有再继续研究。


    // Read first frame of gif image
using (var image = new MagickImage("c:\path\to\Snakeware.gif"))
{
    // Save frame as jpg
    image.Write("c:\path\to\Snakeware.jpg");
}

// Write to stream
var settings = new MagickReadSettings();
// Tells the xc: reader the image to create should be 800x600
settings.Width = 800;
settings.Height = 600;

using (var memStream = new MemoryStream())
{
    // Create image that is completely purple and 800x600
    using (var 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 (var image = new MagickImage("c:\path\to\Snakeware.png"))
{
    // Sets the output format to jpeg
    image.Format = MagickFormat.Jpeg;

    // Create byte array that contains a jpeg file
    byte[] data = image.ToByteArray();
}
0

评论

博主关闭了当前页面的评论