2

I'm following the next example from the Leadtools page https://www.leadtools.com/help/leadtools/v19/dh/co/leadtools.codecs~leadtools.codecs.codecspngoptions.html

The version is the 19

But I'm getting this error in visual studio, {featured not supported}, I don't know what I'm doing wrong?

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

eightShirt
  • 1,457
  • 2
  • 15
  • 29

1 Answers1

2

The most likely cause for this error is failing to load the assembly (codec DLL) for the PNG file format, which is Leadtools.Codecs.Png.dll.

You can either add it as a reference in the .NET project, or copy it to the same folder that has your EXE and other LEADTOOLS assemblies such as Leadtools.Codecs.dll

Our demos avoid such problems because they're all built in the BIN sub-folder for the project's platform. For example, if you build a 32-bit .NET 4 demo, its EXE will be placed in this folder:
LEADTOOLS 19\Bin\Dotnet4\Win32

This folder contains all the LEADTOOLS Dotnet4 assemblies for Win32, including the codecs.

The help topic Files to be Included with Your Application details which assemblies are required for different toolkit features.

If this does not solve the problem for you, please provide more details here or open a support case by emailing LEADTOOLS support.

LEADTOOLS Support
  • 2,755
  • 1
  • 12
  • 12