 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
roger@paxads.com Guest
|
Posted: Mon Nov 14, 2005 7:31 am Post subject: Twain scanner image only works once |
|
|
Can anyone tell me why when using the code below, original code from post of
Johnathan Arnold that when i click the button to call the below function
everyting works great captures image, saves it to jpg format etc, but it
only lets me do it once and to do it again i have to restart the
application.. i also have the same problem if i click cancel to the actual
scanner control form that fires up when it works if i click the button again
nothing happens, restart app and bobs your uncle.
Original code from:
http://www.buddydog.org/C++Builder/c++builder.html
void __fastcall TMainForm::IMG1AquireClick(TObject *Sender)
{
AnsiString tmp_picpath;
HANDLE dib;
LPBITMAPINFO bmi;
if(TwainExists())
{
dib = TwainGetImage(IMG1Aquire->Handle);
if ( dib == 0 )
{
return;
}
bmi = (LPBITMAPINFO)::GlobalLock(dib);
TwainImage->Picture->Bitmap->Height = bmi->bmiHeader.biHeight;
TwainImage->Picture->Bitmap->Width = bmi->bmiHeader.biWidth;
SetDIBits( TwainImage->Picture->Bitmap->Canvas->Handle,
TwainImage->Picture->Bitmap->Handle, 0,
(UINT) bmi->bmiHeader.biHeight,
(Byte*)((Byte*)bmi + sizeof(BITMAPINFOHEADER)),
bmi, DIB_RGB_COLORS );
::GlobalUnlock( dib );
::GlobalFree( dib );
tmp_picpath = session.session_img_path+EpocFromNow()+".jpg";
if(Bitmap2Jpg(TwainImage->Picture->Bitmap,tmp_picpath))
IMG1->Text = tmp_picpath;
else
ShowMessage("Problem converting image.");
}
else
ShowMessage("No devices found.");
}
void __fastcall TMainForm::FormClose(TObject *Sender, TCloseAction &Action)
{
extern HANDLE TwainInst;
FreeLibrary( TwainInst );
} |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|