Ghostscript在x64模式下保持对分色的锁定

时间:2013-06-20 12:54:59

标签: c# ghostscript adobe-illustrator

我正在使用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调用需要作为更大工作流的一部分进行,并且它生成的文件需要进一步处理并最终清理,直到锁被释放才能进行清理。 / p>

举个例子:

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确认的:

Screengrab of procexp.exe, showing locks on the files

出于某种原因,它不会锁定CMYK印版,但它会锁定其他所有印版。

这是奇怪的事情:在32位模式下不会这样做!

如果我使用gsdll32.dll,一切正常,没有锁定。不幸的是,我需要在64位模式下运行它。

我开始使用GS 9.07中的DLL(最新来自他们的网站);无奈之下我已经从源代码下载并重新编译了它们,但发生了同样的事情。

如果你有任何帮助,我会永远爱你!

0 个答案:

没有答案