Click here to Skip to main content
15,897,371 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: complexclass.h ".SetTo" Pin
led mike18-May-07 6:55
led mike18-May-07 6:55 
QuestionError in 'CWnd::Create' : function Pin
sawerr18-May-07 4:34
sawerr18-May-07 4:34 
AnswerRe: Error in 'CWnd::Create' : function Pin
Mark Salsbery18-May-07 4:55
Mark Salsbery18-May-07 4:55 
AnswerRe: Error in 'CWnd::Create' : function Pin
David Crow18-May-07 5:09
David Crow18-May-07 5:09 
QuestionHow to get path of tree elment in text format throgh CTreeCtrl class members Pin
Pankaj.Jain18-May-07 3:29
professionalPankaj.Jain18-May-07 3:29 
AnswerRe: How to get path of tree elment in text format throgh CTreeCtrl class members Pin
James R. Twine18-May-07 3:41
James R. Twine18-May-07 3:41 
QuestionTo use SQL server View Pin
mikobi18-May-07 3:26
mikobi18-May-07 3:26 
QuestionCreate Bitmap From buffer Pin
Md. Mazharul Islam Khan18-May-07 3:25
Md. Mazharul Islam Khan18-May-07 3:25 
I got pbuffer from a camera device. Now i have to make bitmap and show in thumnail view.

LPBYTE pBuffer=new BYTE[height*width*3];
memcpy(pBuffer,(LPBYTE)lParam,height*width*3);

what i did:
DrawThumbnails(){
CBitmap* pImage = NULL;
HBITMAP hBitmap = NULL;

HDC hMemDC = NULL;
HGDIOBJ hOldObj = NULL;
POINT pt;






int x, i; // = m_ImageListThumb.GetImageCount();
CString str;

str.Format("%d",pBuffer);
AfxMessageBox(str);
// no images


// set the length of the space between thumbnails
// you can also calculate and set it based on the length of your list control
int nGap = 6;

// hold the window update to avoid flicking
m_ListThumbnail.SetRedraw(FALSE);

// reset our image list
// for( i=0; i<m_imagelistthumb.getimagecount(); i++)
="" m_imagelistthumb.remove(i);=""
="" remove="" all="" items="" from="" list="" view
="" if(m_listthumbnail.getitemcount()="" !="0)
//" m_listthumbnail.deleteallitems();
="" set="" the="" size="" of="" image="" list
="" m_imagelistthumb.setimagecount(m_vectorimagenames.size());
="" m_imagelistthumb.setimagecount(0);
="" i="0;
"

="" bitmapinfoheader="" bih;
="" memset(="" &bih,="" 0,="" sizeof(="" bih="" )="" );
="" bih.bisize="sizeof(" bih.biwidth="m_nWidth;
" bih.biheight="m_nHeight;
" bih.biplanes="1;
" bih.bibitcount="24;
" bih.bicompression="0;
" bih.bisizeimage="0;
" bih.bixpelspermeter="3780;
" bih.biypelspermeter="3780;
" bih.biclrimportant="0;
" bih.biclrused="0;



" bitmap="" bitmap;
="" memset(&bitmap,0,sizeof(bitmap));
="" bitmap.bmbits="pBuffer;
//" bitmap.bmbitspixel="24;
//" bitmap.bmheight="m_nHeight;
//" bitmap.bmplanes="1;
//" bitmap.bmtype="0X4D42;
//" bitmap.bmwidth="m_nWidth;
//" bitmap.bmwidthbytes="12;

" bitmapinfo="" bmi;

="" bmi.bmiheader="bih;
" put="" bits="" into="" preview="" window="" with="" stretchdibits
="" hwnd="" hwndstill="this-">m_hWnd;




// create thumbnail bitmap section

bih.biWidth = THUMBNAIL_WIDTH;
bih.biHeight = THUMBNAIL_HEIGHT;
// hBitmap = CreateBitmapIndirect(&bitmap);

hBitmap = ::CreateDIBSection(NULL,&bmi, DIB_RGB_COLORS, NULL, NULL, 0);

//hBitmap = ::CreateDIBitmap(hDC,&bih,CBM_INIT,pBuffer,(BITMAPINFO*)&bih,DIB_RGB_COLORS);

//hBitmap = CreateBitmap(m_nWidth,m_nHeight,1,24,)

// restore dib header
//dib.m_pBMI->bmiHeader.biWidth = nWidth;
//dib.m_pBMI->bmiHeader.biHeight = nHeight;
bih.biWidth= m_nWidth;
bih.biHeight = m_nHeight;

// select thumbnail bitmap into screen dc
hMemDC = ::CreateCompatibleDC(NULL);
hOldObj = ::SelectObject(hMemDC, hBitmap);


// HDC hDC = pdc->GetSafeHdc();




::SetStretchBltMode(hMemDC, COLORONCOLOR);

// grayscale image, need palette
// if(dib.m_pPalette != NULL)
// {
// hPal = ::SelectPalette(hMemDC, (HPALETTE)dib.m_pPalette->GetSafeHandle(), FALSE);
// ::RealizePalette(hMemDC);
// }

// set stretch mode
//::SetStretchBltMode(hMemDC, COLORONCOLOR);

// populate the thumbnail bitmap bits
// ::StretchDIBits(hMemDC, 0, 0,
// THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT,
// 0, 0,
// dib.m_pBMI->bmiHeader.biWidth,
// dib.m_pBMI->bmiHeader.biHeight,
// dib.m_pBits,
// dib.m_pBMI,
// DIB_RGB_COLORS,
// SRCCOPY);

::StretchDIBits(
hMemDC, 0, 0,
THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, //lStillWidth, lStillHeight,
0, 0, m_nWidth, m_nHeight,
pBuffer,
&bmi,
DIB_RGB_COLORS,
SRCCOPY);

//EndPaint(&ps);

// restore DC object
// ::SelectObject(hMemDC, hOldObj);

// restore DC palette
// if(dib.m_pPalette != NULL)
// ::SelectPalette(hMemDC, (HPALETTE)hPal, FALSE);

// clean up
::DeleteObject(hMemDC);
// ReleaseDC(pdc);

// attach the thumbnail bitmap handle to an CBitmap object
pImage = new CBitmap();
pImage->Attach(hBitmap);






// add bitmap to our image list
m_ImageListThumb.Replace(i, pImage, NULL);
//x= m_ImageListThumb.GetImageCount();




// put item to display
// set the image file name as item text
m_ListThumbnail.InsertItem(i, NULL, i);



// get current item position
m_ListThumbnail.GetItemPosition(i, &pt);
//
// shift the thumbnail to desired position
pt.x = nGap + i*(THUMBNAIL_WIDTH + nGap);
m_ListThumbnail.SetItemPosition(i, pt);
i++;
str.Format("%d",i);
AfxMessageBox(str);


// let's show the new thumbnails
m_ListThumbnail.SetRedraw(TRUE);



}

the probable problem is in CreateDibSection

Can any one help me?

Mazhar
AnswerRe: Create Bitmap From buffer Pin
Chris Losinger18-May-07 5:40
professionalChris Losinger18-May-07 5:40 
QuestionHow to send a dos command to system as we do in cmd prompt interface Pin
zhongwenjia18-May-07 2:53
zhongwenjia18-May-07 2:53 
AnswerRe: How to send a dos command to system as we do in cmd prompt interface Pin
Arman S.18-May-07 2:57
Arman S.18-May-07 2:57 
AnswerRe: How to send a dos command to system as we do in cmd prompt interface Pin
CPallini18-May-07 3:08
mveCPallini18-May-07 3:08 
AnswerRe: How to send a dos command to system as we do in cmd prompt interface Pin
James R. Twine18-May-07 3:09
James R. Twine18-May-07 3:09 
AnswerRe: How to send a dos command to system as we do in cmd prompt interface Pin
toxcct18-May-07 3:12
toxcct18-May-07 3:12 
Questionvc++ plus multiple database support? Pin
$uresh $hanmugam18-May-07 1:55
$uresh $hanmugam18-May-07 1:55 
AnswerRe: vc++ plus multiple database support? Pin
James R. Twine18-May-07 2:00
James R. Twine18-May-07 2:00 
AnswerRe: vc++ plus multiple database support? Pin
Hamid_RT18-May-07 2:01
Hamid_RT18-May-07 2:01 
GeneralRe: vc++ plus multiple database support? Pin
$uresh $hanmugam18-May-07 2:13
$uresh $hanmugam18-May-07 2:13 
AnswerRe: vc++ plus multiple database support? Pin
Nemanja Trifunovic18-May-07 4:06
Nemanja Trifunovic18-May-07 4:06 
Questionstatic member function Pin
Kiran Pinjala18-May-07 1:45
Kiran Pinjala18-May-07 1:45 
AnswerRe: static member function Pin
CPallini18-May-07 1:58
mveCPallini18-May-07 1:58 
AnswerRe: static member function Pin
Manoj Kumar Rai18-May-07 3:04
professionalManoj Kumar Rai18-May-07 3:04 
QuestionCreate 16-bit process Pin
Hans Ruck18-May-07 1:33
Hans Ruck18-May-07 1:33 
AnswerRe: Create 16-bit process Pin
led mike18-May-07 4:16
led mike18-May-07 4:16 
GeneralRe: Create 16-bit process Pin
Hans Ruck18-May-07 4:24
Hans Ruck18-May-07 4:24 

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.