PDFPatcher icon indicating copy to clipboard operation
PDFPatcher copied to clipboard

能不能提供64位的PDF补丁丁呢?

Open Charltsing opened this issue 2 years ago • 6 comments

现在电脑文件都挺大的,PDF补丁丁是否支持64位?

Charltsing avatar May 07 '23 06:05 Charltsing

应该有可能,只是所有用 C 写的库都要重新编译。 等正式版发布了之后,下个版本将转到64位平台。

wmjordan avatar May 07 '23 08:05 wmjordan

C#可以支持原生库的Anycpu,只要给原生库的API做个包装,类似这样

代码: `[SuppressUnmanagedCodeSecurity] //调用非托管代码时执行的堆栈遍视在运行时被省略,从而大幅节省性能。 internal sealed class JBIG2EncNativeMethods {

    [DllImport("JBig2losslessEnc-x86.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, EntryPoint = "jbig2_vernumber")]
    private static extern int JBIG2EncodeVerNum_x86();
    [DllImport("JBig2losslessEnc-x64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, EntryPoint = "jbig2_vernumber")]
    private static extern int JBIG2EncodeVerNum_x64();

    [DllImport("JBig2losslessEnc-x86.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, EntryPoint = "jbig2_version")]
    private static extern IntPtr JBIG2EncodeVer_x86();
    [DllImport("JBig2losslessEnc-x64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, EntryPoint = "jbig2_version")]
    private static extern IntPtr JBIG2EncodeVer_x64();
    public static int JBIG2EncodeVer(out string Ver)
    {
        Ver = string.Empty;
        int vernum;
        if (IntPtr.Size == 4)
            vernum = JBIG2EncodeVerNum_x86();
        else
            vernum = JBIG2EncodeVerNum_x64();

        IntPtr p;
        if (IntPtr.Size == 4)
            p = JBIG2EncodeVer_x86();
        else
            p = JBIG2EncodeVer_x64();

        if (p!=IntPtr.Zero) Ver = Marshal.PtrToStringAnsi(p);

        return vernum;
    }


    [DllImport("JBig2losslessEnc-x86.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "jbig2_encode")]
    private static extern IntPtr Encode_x86(int width, int height, int stride, bool zeroIsWhite, IntPtr data, ref int length);

    [DllImport("JBig2losslessEnc-x64.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "jbig2_encode")]
    private static extern IntPtr Encode_x64(int width, int height, int stride, bool zeroIsWhite, IntPtr data, ref int length);
    public static IntPtr Encode(int width, int height, int stride, bool zeroIsWhite, IntPtr data, ref int length)
    {
        if (IntPtr.Size == 4)
            return Encode_x86(width, height, stride, zeroIsWhite, data, ref length);
        else
            return Encode_x64(width, height, stride, zeroIsWhite, data, ref length);            
    }


    [DllImport("JBig2losslessEnc-x86.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "release")]
    private static extern IntPtr Release_x86(IntPtr data);
    [DllImport("JBig2losslessEnc-x64.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "release")]
    private static extern IntPtr Release_x64(IntPtr data);
    public static IntPtr Release(IntPtr data)
    {
        if (IntPtr.Size == 4)
            return Release_x86(data);
        else
            return Release_x64(data);
    }
}`

Charltsing avatar May 08 '23 13:05 Charltsing

C#可以支持原生库的Anycpu,只要给原生库的API做个包装,类似这样 `[SuppressUnmanagedCodeSecurity] //调用非托管代码时执行的堆栈遍视在运行时被省略,从而大幅节省性能。 internal sealed class JBIG2EncNativeMethods { //https://hub.njuu.cf/AndreyAkinshin/InteropDotNet 通过LoadLibrary和GetProcAddress实现。

    [DllImport("JBig2losslessEnc-x86.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, EntryPoint = "jbig2_vernumber")]
    private static extern int JBIG2EncodeVerNum_x86();
    [DllImport("JBig2losslessEnc-x64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, EntryPoint = "jbig2_vernumber")]
    private static extern int JBIG2EncodeVerNum_x64();

    [DllImport("JBig2losslessEnc-x86.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, EntryPoint = "jbig2_version")]
    private static extern IntPtr JBIG2EncodeVer_x86();
    [DllImport("JBig2losslessEnc-x64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, EntryPoint = "jbig2_version")]
    private static extern IntPtr JBIG2EncodeVer_x64();
    public static int JBIG2EncodeVer(out string Ver)
    {
        Ver = string.Empty;
        int vernum;
        if (IntPtr.Size == 4)
            vernum = JBIG2EncodeVerNum_x86();
        else
            vernum = JBIG2EncodeVerNum_x64();

        IntPtr p;
        if (IntPtr.Size == 4)
            p = JBIG2EncodeVer_x86();
        else
            p = JBIG2EncodeVer_x64();

        if (p!=IntPtr.Zero) Ver = Marshal.PtrToStringAnsi(p);

        return vernum;
    }


    [DllImport("JBig2losslessEnc-x86.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "jbig2_encode")]
    private static extern IntPtr Encode_x86(int width, int height, int stride, bool zeroIsWhite, IntPtr data, ref int length);

    [DllImport("JBig2losslessEnc-x64.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "jbig2_encode")]
    private static extern IntPtr Encode_x64(int width, int height, int stride, bool zeroIsWhite, IntPtr data, ref int length);
    public static IntPtr Encode(int width, int height, int stride, bool zeroIsWhite, IntPtr data, ref int length)
    {
        if (IntPtr.Size == 4)
            return Encode_x86(width, height, stride, zeroIsWhite, data, ref length);
        else
            return Encode_x64(width, height, stride, zeroIsWhite, data, ref length);            
    }


    [DllImport("JBig2losslessEnc-x86.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "release")]
    private static extern IntPtr Release_x86(IntPtr data);
    [DllImport("JBig2losslessEnc-x64.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "release")]
    private static extern IntPtr Release_x64(IntPtr data);
    public static IntPtr Release(IntPtr data)
    {
        if (IntPtr.Size == 4)
            return Release_x86(data);
        else
            return Release_x64(data);
    }
}`

Charltsing avatar May 08 '23 13:05 Charltsing