Click here to Skip to main content
15,921,530 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Reboot windows 95 machines Pin
Nish Nishant6-Nov-01 9:01
sitebuilderNish Nishant6-Nov-01 9:01 
GeneralRe: Reboot windows 95 machines Pin
RobJones6-Nov-01 9:06
RobJones6-Nov-01 9:06 
GeneralImage Acquisition Pin
Chambers6-Nov-01 7:15
Chambers6-Nov-01 7:15 
GeneralRe: Image Acquisition Pin
Chris Losinger6-Nov-01 7:21
professionalChris Losinger6-Nov-01 7:21 
GeneralRe: Image Acquisition Pin
#realJSOP6-Nov-01 7:46
professional#realJSOP6-Nov-01 7:46 
GeneralRe: Image Acquisition Pin
Chambers7-Nov-01 2:25
Chambers7-Nov-01 2:25 
GeneralRe: Image Acquisition Pin
Chris Losinger7-Nov-01 2:49
professionalChris Losinger7-Nov-01 2:49 
GeneralRe: Image Acquisition Pin
Chambers7-Nov-01 5:00
Chambers7-Nov-01 5:00 
OK, I have actually managed to solve the problem, but I`d still appreciate it if you could tell me whether this code is efficient, and if not an alternative approach to solving the problem. The code below is generated from the OnAquisitionClick() function (which does all the TWAIN stuff) and passes the results to the AcquireImage() function, both of which are located in the MainFrame class of an MDI app. right here goes:

void CMainFrame::AcquireImage(HBITMAP hbitmap, TW_IMAGEINFO& info)
{
CBitmapDoc* pBitmapDoc = NewDocument();   //new doc.
CBitmapFrame* pBitmapWnd = (CBitmapFrame*)NewWindow(pBitmapDoc);

BYTE* lpVoid, *pBits;
LPBITMAPINFO pHead;

lpVoid = (BYTE*)GlobalLock(hbitmap);
pHead = (LPBITMAPINFO)lpVoid;
if(pHead->bmiHeader.biCompression != BI_RGB || pHead->bmiHeader.biBitCount != 24)
{
GlobalUnlock(lpVoid);
return;
}

pBits = (BYTE*)lpVoid + sizeof(BITMAPINFOHEADER);
HBITMAP newbitmap = CreateDIBitmap(pBitmapWnd->GetDC()->m_hDC, &pHead->bmiHeader, CBM_INIT, pBits, pHead, DIB_RGBCOLORS);

if(newbitmap)
{
pBitmapDoc->m_hAppliedTools.push_back(newbitmap); //stores all the layers in order for drawing later.
pBitmapWnd->SetMinMaxWndSize(pHead->bmiHeader.biWidth, pHead->bmiHeader.biHeight);
pBitmapWnd->AddDYNAMenu(m_hFilters, m_hTools);
pBitmapDoc->SetTitle("Acquired");
m_hBitmapTemplate->InitialUpdateFrame(pBitmapWnd, pBitmapDoc, TRUE);
return;
}
else
AfxMessageBox("Cannot create new image acquisition graphic");

}


The one thing I do notice is that although I get all my information from hbitmap, if I try to use that Handle, the image is not drawn at all! I think, now that I`ve got this working, I may be able to figure out some better code to the job (I noticed some areas when I was just typing it out). One other thing, hbitmap may have been ascertained from the scanner as a HANDLE and not a HBITMAP (what I mean by that is that I could pass a HANDLE to one of the TWAIN acquire procedures and it still works). The handle is then passed to the procedure above. Hope you can enlighten/reassure me on my code.

Thanks again Chris,
AlanBig Grin | :-D

"When I left you I was but the learner, now I am the Master" - Darth VaderMad | :mad:
GeneralImage Color Management (ICM) Pin
6-Nov-01 7:03
suss6-Nov-01 7:03 
GeneralLog deletes in BoundsChecker Pin
peterchen6-Nov-01 7:00
peterchen6-Nov-01 7:00 
Generalsys/socket.h Pin
6-Nov-01 5:42
suss6-Nov-01 5:42 
GeneralRe: sys/socket.h Pin
Tim Smith6-Nov-01 6:22
Tim Smith6-Nov-01 6:22 
GeneralRe: sys/socket.h Pin
Anders Molin6-Nov-01 7:11
professionalAnders Molin6-Nov-01 7:11 
GeneralMessage from external app should: Open document and goto line # Pin
Steve Schaneville6-Nov-01 4:48
professionalSteve Schaneville6-Nov-01 4:48 
GeneralRe: Message from external app should: Open document and goto line # Pin
6-Nov-01 6:32
suss6-Nov-01 6:32 
GeneralRe: Message from external app should: Open document and goto line # Pin
Steve Schaneville6-Nov-01 6:56
professionalSteve Schaneville6-Nov-01 6:56 
GeneralRe: Message from external app should: Open document and goto line # Pin
Ben Burnett6-Nov-01 7:12
Ben Burnett6-Nov-01 7:12 
GeneralRepeat the song... (VFW.lib) Pin
Rickard Andersson206-Nov-01 4:31
Rickard Andersson206-Nov-01 4:31 
GeneralRe: Repeat the song... (VFW.lib) Pin
Rassman6-Nov-01 4:52
Rassman6-Nov-01 4:52 
GeneralRe: Repeat the song... (VFW.lib) Pin
Ben Burnett6-Nov-01 9:53
Ben Burnett6-Nov-01 9:53 
GeneralFlex Grid ! Pin
Hadi Rezaee6-Nov-01 4:21
Hadi Rezaee6-Nov-01 4:21 
GeneralRe: Flex Grid ! Pin
Rassman6-Nov-01 5:03
Rassman6-Nov-01 5:03 
GeneralRe: Flex Grid ! Pin
Hadi Rezaee6-Nov-01 6:34
Hadi Rezaee6-Nov-01 6:34 
GeneralRe: Flex Grid ! Pin
Hadi Rezaee6-Nov-01 16:03
Hadi Rezaee6-Nov-01 16:03 
GeneralRe: Flex Grid ! Pin
Jon Hulatt6-Nov-01 22:22
Jon Hulatt6-Nov-01 22:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.