我正在使用 Ghostscript 的 DLL (gsdll[32|64].dll) 来处理 Adobe Illustrator 文件的 TIFF 分色。我的代码在 C# .NET 中并在 Windows 中运行。
对于背景信息,我使用“tiffsep”设备创建每个印版的 TIFF,然后通过 GDI 将它们转换为 JPG 以显示在 UI 中。
问题是,当使用 64 位 DLL 时,Ghostscript 会保留对某些分隔符的锁定。这是我正在使用调用 DLL 的代码:
private static void ExecuteGs64(string[] args)
{
IntPtr instancePtr;
lock (instanceLock)
{
NativeMethods.CreateAPIInstance64(out instancePtr, IntPtr.Zero);
try
{
int result = NativeMethods.InitAPI64(instancePtr, args.Length, args);
if (result < 0)
{
throw new ExternalException("Ghostscript conversion error " + result, result);
}
}
finally
{
// according to GS docs, this should clean up any memory used
NativeMethods.ExitAPI64(instancePtr);
NativeMethods.DeleteAPIInstance64(instancePtr);
}
}
}
internal static class NativeMethods
{
[DllImport("gsdll64.dll", EntryPoint = "gsapi_new_instance")]
internal static extern int CreateAPIInstance64(out IntPtr pinstance, IntPtr caller_handle);
[DllImport("gsdll64.dll", EntryPoint = "gsapi_init_with_args")]
internal static extern int InitAPI64(IntPtr instance, int argc, string[] argv);
[DllImport("gsdll64.dll", EntryPoint = "gsapi_exit")]
internal static extern int ExitAPI64(IntPtr instance);
[DllImport("gsdll64.dll", EntryPoint = "gsapi_delete_instance")]
internal static extern void DeleteAPIInstance64(IntPtr instance);
}
我正在使用以下参数运行它:
-q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dEPSCrop -dMaxBitmap=500000000 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dAutoRotatePages=/None -dAlignToPixels=0 -dGridFitTT=0 -dFirstPage=1 -dLastPage=1 -sDEVICE=tiffsep -r150x150 -sOutputFile=[OutPath] [InPath]
代码运行,GS 生成分色。然而,一些分离仍然被应用程序锁定(我尝试将 GS 代码从主应用程序中取出并在测试控制台应用程序中运行它,没有其他任何事情发生,同样的结果)。这些锁一直保持到应用程序停止。
对我来说,这是一个问题,因为 GS 调用需要作为更大工作流程的一部分进行,并且它生成的文件需要进一步处理和最终清理,这在释放锁之前无法发生。
举个例子:
Original file: BGL1100001A01.ai
Outputs (L denotes which files are locked):
[ ] BGL1100001A01(Black).tif
[L] BGL1100001A01(Cutter Guide).tif
[ ] BGL1100001A01(Cyan).tif
[ ] BGL1100001A01(Magenta).tif
[L] BGL1100001A01(PANTONE 143 C).tif
[L] BGL1100001A01(PANTONE 201 C).tif
[L] BGL1100001A01(PANTONE 360 C).tif
[L] BGL1100001A01(PANTONE 485 C).tif
[L] BGL1100001A01(PANTONE 488 C).tif
[L] BGL1100001A01(Spot White).tif
[ ] BGL1100001A01(Yellow).tif
[L] BGL1100001A01.tif
procexp.exe 证实了这一点:
出于某种原因,它不会锁定 CMYK 印版,但会锁定其他所有内容。
奇怪的是:它在 32 位模式下不这样做!
如果我使用 gsdll32.dll,一切正常,并且没有锁定。不幸的是,我需要在 64 位模式下运行它。
我首先使用 GS 9.07 的 DLL(来自他们网站的最新版本);绝望中,我从源代码下载并重新编译了它们,但完全相同的事情正在发生。
如果你有任何帮助,我会永远爱你!!!