0
我使用WinFax.dll在我的應用程序中發送和接收傳真,它現在工作得相當好。問題是我想將圖像信息保存在FaxJob中,但輸出不是任何可識別的格式。保存傳真作業的圖像數據
我已經嘗試過Tiff,Gif,Bmp,Png和Jpg,但它不能正常工作,所以我認爲在我如何做這件事上可能存在問題。這裏的源代碼,我都用來獲取圖像:
public class FaxJob
{
public Image GetImage()
{
uint width;
uint height;
uint size;
byte[] data;
IntPtr buffer;
if (NativeMethods.FaxGetPageData(this.Server.faxHandle, this.id, out buffer, out size, out width, out height) == false)
throw FaxTools.CreateFaxException(string.Empty);
data = new byte[size];
Marshal.Copy(buffer, data, 0, Convert.ToInt32(size));
var ms = new MemoryStream();
ms.Write(data, 0, data.Length);
var img = Image.FromStream(ms);
return img;
}
}
internal class NativeMethods
{
[DllImport("WinFax.dll", SetLastError = true, EntryPoint = "FaxGetPageData")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool FaxGetPageData(IntPtr FaxHandle, uint JobId, out IntPtr Buffer, out uint BufferSize, out uint ImageWidth, out uint ImageHeight);
}
這似乎爲圖像的寬度和高度運作良好返回和字節[]包含的圖像數據。
任何想法非常感謝。