-1
使用雙掃描器和Mdi格式的代碼顯示輸出進行掃描我需要將它顯示在一個picturebox內,是否有可能?我嘗試了一些關於將intptr轉換爲圖像或somethnig,但沒有找到正確的方法。Twain掃描輸出將intptr轉換爲圖像
代碼如下;
case TwainCommand.TransferReady:
{
ArrayList pics = tw.TransferPictures();
EndingScan();
tw.CloseSrc();
picnumber++;
for (int i = 0; i < pics.Count; i++)
{
IntPtr img = (IntPtr)pics[i];
PicForm newpic = new PicForm(img);
newpic.MdiParent = this;
int picnum = i + 1;
newpic.Text = "ScanPass" + picnumber.ToString() + "_Pic" + picnum.ToString();
newpic.Show();
}
break;
public ArrayList TransferPictures()
{
ArrayList pics = new ArrayList();
if(srcds.Id == IntPtr.Zero)
return pics;
TwRC rc;
IntPtr hbitmap = IntPtr.Zero;
TwPendingXfers pxfr = new TwPendingXfers();
do
{
pxfr.Count = 0;
hbitmap = IntPtr.Zero;
TwImageInfo iinf = new TwImageInfo();
rc = DSiinf(appid, srcds, TwDG.Image, TwDAT.ImageInfo, TwMSG.Get, iinf);
if(rc != TwRC.Success)
{
CloseSrc();
return pics;
}
rc = DSixfer(appid, srcds, TwDG.Image, TwDAT.ImageNativeXfer, TwMSG.Get, ref hbitmap);
if(rc != TwRC.XferDone)
{
CloseSrc();
return pics;
}
rc = DSpxfer(appid, srcds, TwDG.Control, TwDAT.PendingXfers, TwMSG.EndXfer, pxfr);
if(rc != TwRC.Success)
{
CloseSrc();
return pics;
}
pics.Add(hbitmap);
}
while(pxfr.Count != 0);
rc = DSpxfer(appid, srcds, TwDG.Control, TwDAT.PendingXfers, TwMSG.Reset, pxfr);
return pics;
}