public DjvuFileInfo GetFileInfo(int fileNumber) { if (fileNumber < 0 || fileNumber >= FileCount) { throw new ArgumentOutOfRangeException(nameof(fileNumber)); } DjvuFileInfo info = null; int status = 0; int size = Marshal.SizeOf <DjvuFileInfo>(); IntPtr buffer = Marshal.AllocHGlobal(size); status = NativeMethods.GetDjvuDocumentFileInfo(Document, fileNumber, buffer, size); // DjvuDocumentInfo is not initialized if (status < 2) { return(null); } if (status == 2) { info = DjvuFileInfo.GetDjvuFileInfo(buffer); Marshal.FreeHGlobal(buffer); return(info); } else { throw new ApplicationException($"Failed to get PageInfo for page number: {fileNumber}"); } }
public static DjvuFileInfo GetDjvuFileInfo(IntPtr nativeInfo) { NativeFileInfo infoNative = Marshal.PtrToStructure <NativeFileInfo>(nativeInfo); DjvuFileInfo info = new DjvuFileInfo(infoNative); return(info); }