You can use the Bitmap Constructor. More info can be found at: http://msdn.microsoft.com/en-us/library/zy1a2d14.aspx
Twain scan output convert intptr to image
-
29-06-2023 - |
سؤال
Scanning with twain scanner and code display output inside Mdi form I need to display it inside a picturebox , is it possible? I try some about converting intptr to image or somethnig but didnt find the correct way.
code down below;
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;
}
المحلول
لا تنتمي إلى StackOverflow