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, Alan:-D "When I left you I was but the learner, now I am the Master" - Darth Vader:mad: