Click here to Skip to main content
15,908,254 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: size of dialog in resource editor Pin
Larry J. Siddens18-May-07 5:29
Larry J. Siddens18-May-07 5:29 
GeneralRe: size of dialog in resource editor Pin
ldsdbomber18-May-07 5:31
ldsdbomber18-May-07 5:31 
GeneralRe: size of dialog in resource editor Pin
Larry J. Siddens18-May-07 5:33
Larry J. Siddens18-May-07 5:33 
AnswerRe: size of dialog in resource editor Pin
David Crow18-May-07 6:43
David Crow18-May-07 6:43 
QuestionUse object of an external class Pin
dodoxor18-May-07 5:12
dodoxor18-May-07 5:12 
AnswerRe: Use object of an external class Pin
Larry J. Siddens18-May-07 5:26
Larry J. Siddens18-May-07 5:26 
QuestionRe: Use object of an external class Pin
dodoxor18-May-07 6:39
dodoxor18-May-07 6:39 
AnswerRe: Use object of an external class Pin
Mark Salsbery18-May-07 5:30
Mark Salsbery18-May-07 5:30 
QuestionRe: Use object of an external class Pin
dodoxor18-May-07 6:40
dodoxor18-May-07 6:40 
AnswerRe: Use object of an external class Pin
Mark Salsbery18-May-07 6:54
Mark Salsbery18-May-07 6:54 
Questioncomplexclass.h ".SetTo" Pin
simoncoul18-May-07 5:07
simoncoul18-May-07 5:07 
AnswerRe: complexclass.h ".SetTo" Pin
led mike18-May-07 5:33
led mike18-May-07 5:33 
GeneralRe: complexclass.h ".SetTo" Pin
simoncoul18-May-07 5:47
simoncoul18-May-07 5:47 
QuestionRe: complexclass.h ".SetTo" Pin
Mark Salsbery18-May-07 5:33
Mark Salsbery18-May-07 5:33 
AnswerRe: complexclass.h ".SetTo" Pin
led mike18-May-07 6:05
led mike18-May-07 6:05 
GeneralRe: complexclass.h ".SetTo" Pin
Mark Salsbery18-May-07 6:13
Mark Salsbery18-May-07 6:13 
GeneralRe: complexclass.h ".SetTo" Pin
simoncoul18-May-07 6:23
simoncoul18-May-07 6:23 
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

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.