LEADTOOLS解压缩示例获取异常

时间:2016-01-11 23:01:16

标签: c# leadtools-sdk

我正在关注Leadtools页面中的下一个示例 https://www.leadtools.com/help/leadtools/v19/dh/co/leadtools.codecs~leadtools.codecs.codecspngoptions.html

版本是19

但我在视觉工作室遇到这个错误,{不支持},我不知道我做错了什么?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Leadtools;
using Leadtools.Codecs;


namespace DicomTest3
{
    public class Program
    {
        public static void Main(string[] args)
        {
            const string LEAD_VARS = @"C:\Users\Public\Documents\LEADTOOLSImages";

            RasterSupport.SetLicense(
                @"C:\LEADTOOLS 19\Common\License\LEADTOOLS.LIC",
                File.ReadAllText(@"C:\LEADTOOLS 19\Common\License\LEADTOOLS.LIC.KEY")
            );

            RasterCodecs codecs = new RasterCodecs();
            string srcFileName = Path.Combine(LEAD_VARS, "IMAGE1.CMP");
            RasterImage image = codecs.Load(srcFileName);

            // save with maximum quality
            codecs.Options.Png.Save.QualityFactor = 1;
            codecs.Save(image, Path.Combine(LEAD_VARS, "quality.png"), RasterImageFormat.Png, image.BitsPerPixel);

            // save with maximum compression
            codecs.Options.Png.Save.QualityFactor = 9;
            codecs.Save(image, Path.Combine(LEAD_VARS, "compression.png"), RasterImageFormat.Png, image.BitsPerPixel);

            // Clean up
            image.Dispose();
            codecs.Dispose();
        }

    }
}

Error during debugging

1 个答案:

答案 0 :(得分:2)

导致此错误的最可能原因是无法加载PNG文件格式的程序集(编解码器DLL),即Leadtools.Codecs.Png.dll。

您可以将其添加为.NET项目中的引用,或将其复制到具有EXE和其他LEADTOOLS程序集的同一文件夹,例如Leadtools.Codecs.dll

我们的演示避免了这些问题,因为它们都是在项目平台的BIN子文件夹中构建的。例如,如果您构建32位.NET 4演示,则其EXE将放在此文件夹中:
LEADTOOLS 19 \ Bin \ Dotnet4 \ Win32

此文件夹包含Win32的所有LEADTOOLS Dotnet4程序集,包括编解码器。

帮助主题Files to be Included with Your Application详细说明了不同工具包功能所需的程序集。

如果这不能解决您的问题,请在此处提供更多详细信息,或通过电子邮件向LEADTOOLS支持人员打开支持案例。