Click here to Skip to main content
15,896,726 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Encode two integers! Pin
Prakash Nadar15-Oct-05 19:04
Prakash Nadar15-Oct-05 19:04 
GeneralRe: Encode two integers! Pin
JoaoPe15-Oct-05 19:22
JoaoPe15-Oct-05 19:22 
GeneralRe: Encode two integers! Pin
begray15-Oct-05 22:24
begray15-Oct-05 22:24 
GeneralRe: Encode two integers! Pin
JoaoPe16-Oct-05 2:38
JoaoPe16-Oct-05 2:38 
GeneralRe: Encode two integers! Pin
Chris Losinger16-Oct-05 3:44
professionalChris Losinger16-Oct-05 3:44 
GeneralRe: Encode two integers! Pin
Bob Stanneveld16-Oct-05 10:46
Bob Stanneveld16-Oct-05 10:46 
GeneralRe: Encode two integers! Pin
ThatsAlok16-Oct-05 18:54
ThatsAlok16-Oct-05 18:54 
QuestionDIBitmap Pin
daojinliu15-Oct-05 15:46
daojinliu15-Oct-05 15:46 
int the function OnDraw();I want to create a DIB bitmap using the array pData,and display it on the screen,but I am not fail to do it;Would please tell me how to correct the codes below.

//the array containing color information
unsigned char* pData=new unsigned char[768*576*3];
int y=0, x=0;
for(;y<576;y++)
for(;x<768;x++)
{
pData[x*3+y*768*3]=0;
pData[x*3+1+y*768*3]=0;
pData[x*3+2+y*768*3]=255;
}
//information header

BITMAPINFOHEADER FrameBmi;
FrameBmi.biSize=sizeof(BITMAPINFOHEADER);
FrameBmi.biPlanes=1;
FrameBmi.biCompression=BI_RGB;
FrameBmi.biClrImportant=0;
FrameBmi.biSizeImage=768*576*3;
FrameBmi.biClrUsed=0;
FrameBmi.biBitCount=24;
FrameBmi.biWidth=768;
FrameBmi.biHeight=576;
FrameBmi.biXPelsPerMeter = 0;
FrameBmi.biYPelsPerMeter =0;
//file header
BITMAPFILEHEADER pf;
pf.bfType=0x4d42; //"BM"
pf.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+sizeof(char[768*576]);
pf.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
pf.bfReserved1=0;
pf.bfReserved2=0;

//BITMAPINFOHEADER
LPBITMAPINFO lpbmi=(LPBITMAPINFO)GlobalAlloc(GMEM_FIXED,sizeof(BITMAPINFOHEADER));
ASSERT(lpbmi);
lpbmi->bmiHeader.biSize=FrameBmi.biSize;
lpbmi->bmiHeader.biPlanes=FrameBmi.biPlanes;
lpbmi->bmiHeader.biCompression=FrameBmi.biCompression;
lpbmi->bmiHeader.biClrImportant=FrameBmi.biClrImportant;
lpbmi->bmiHeader.biSizeImage=FrameBmi.biSizeImage;
lpbmi->bmiHeader.biClrUsed=FrameBmi.biClrUsed;
lpbmi->bmiHeader.biBitCount=FrameBmi.biBitCount;
lpbmi->bmiHeader.biWidth=FrameBmi.biWidth;
lpbmi->bmiHeader.biHeight=FrameBmi.biHeight;
lpbmi->bmiHeader.biXPelsPerMeter=FrameBmi.biXPelsPerMeter;
lpbmi->bmiHeader.biYPelsPerMeter=FrameBmi.biYPelsPerMeter;
lpbmi->bmiColors=NULL;

//Create DIBitmap
CBitmap *OldBitmap;
HBITMAP bmp =::CreateDIBitmap((HDC)pDC,&FrameBmi,CBM_INIT,pData,lpbmi, DIB_RGB_COLORS);
ASSERT(bmp);
//
CBitmap bitmap;
bitmap.Attach(bmp);
CDC dcComp;
dcComp.CreateCompatibleDC(pDC);
OldBitmap=dcComp.SelectObject(&bitmap);
BITMAP bm;
bitmap.GetObject(sizeof(BITMAP),&bm);

// draw bitmap
pDC->BitBlt(0,0,768,576,&dcComp,0,0,SRCCOPY);
dcComp.SelectObject(OldBitmap);
delete [] pData;
GlobalFree(lpbmi);
delteDC(dcComp);


I LOVE VC

-- modified at 6:43 Sunday 16th October, 2005
AnswerRe: DIBitmap Pin
Chris Losinger15-Oct-05 16:56
professionalChris Losinger15-Oct-05 16:56 
GeneralRe: DIBitmap Pin
daojinliu15-Oct-05 18:24
daojinliu15-Oct-05 18:24 
GeneralRe: DIBitmap Pin
Chris Losinger15-Oct-05 18:45
professionalChris Losinger15-Oct-05 18:45 
GeneralRe: DIBitmap Pin
PJ Arends15-Oct-05 20:54
professionalPJ Arends15-Oct-05 20:54 
GeneralRe: DIBitmap Pin
daojinliu16-Oct-05 0:40
daojinliu16-Oct-05 0:40 
GeneralRe: DIBitmap Pin
PJ Arends16-Oct-05 8:09
professionalPJ Arends16-Oct-05 8:09 
QuestionREQ : Question with message box. Pin
zerofire15-Oct-05 15:42
zerofire15-Oct-05 15:42 
AnswerRe: REQ : Question with message box. Pin
David Crow15-Oct-05 16:15
David Crow15-Oct-05 16:15 
AnswerRe: REQ : Question with message box. Pin
Jack Puppy15-Oct-05 16:19
Jack Puppy15-Oct-05 16:19 
GeneralRe: REQ : Question with message box. Pin
zerofire15-Oct-05 16:27
zerofire15-Oct-05 16:27 
AnswerRe: REQ : Question with message box. Pin
daojinliu16-Oct-05 0:52
daojinliu16-Oct-05 0:52 
QuestionHow to delete a class? Pin
kevincwong15-Oct-05 15:37
kevincwong15-Oct-05 15:37 
AnswerRe: How to delete a class? Pin
daojinliu15-Oct-05 15:56
daojinliu15-Oct-05 15:56 
GeneralRe: How to delete a class? Pin
kevincwong15-Oct-05 16:45
kevincwong15-Oct-05 16:45 
QuestionEnumerate (list) USB Webcams Pin
Howard Anderson15-Oct-05 15:27
Howard Anderson15-Oct-05 15:27 
AnswerRe: Enumerate (list) USB Webcams Pin
FlyingTinman19-Oct-05 16:09
FlyingTinman19-Oct-05 16:09 
GeneralRe: Enumerate (list) USB Webcams Pin
Howard Anderson10-Nov-05 4:31
Howard Anderson10-Nov-05 4:31 

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.