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

C / C++ / MFC

 
AnswerRe: Run an application inside another one Pin
Jun Du7-Jul-06 4:40
Jun Du7-Jul-06 4:40 
QuestionCListCtrl and Graphic Pin
ensger7-Jul-06 3:44
ensger7-Jul-06 3:44 
AnswerRe: CListCtrl and Graphic Pin
Zac Howland7-Jul-06 5:25
Zac Howland7-Jul-06 5:25 
GeneralRe: CListCtrl and Graphic Pin
ensger7-Jul-06 9:10
ensger7-Jul-06 9:10 
QuestionCreating a Bitmap from a Framegrabber Image Pin
im797-Jul-06 3:41
im797-Jul-06 3:41 
AnswerRe: Creating a Bitmap from a Framegrabber Image Pin
Justin Tay7-Jul-06 6:27
Justin Tay7-Jul-06 6:27 
AnswerRe: Creating a Bitmap from a Framegrabber Image Pin
im799-Jul-06 4:37
im799-Jul-06 4:37 
GeneralRe: Creating a Bitmap from a Framegrabber Image Pin
Justin Tay9-Jul-06 11:40
Justin Tay9-Jul-06 11:40 
im79 wrote:
i don't have a BITMAPINFO, can make one manualy?


If you know what kind of data is in the pixel array, you should have no problem populating the header.

I've just written and tested this by generating a grayscale gradient and it works.

HBITMAP CreateGrayscaleBitmap(int nWidth, int nHeight, LPBYTE pData)
{
  BITMAPINFO *pbmi = (BITMAPINFO*) new BYTE[sizeof(BITMAPINFO) + (sizeof(RGBQUAD) * 256)];
  ZeroMemory(pbmi, sizeof(BITMAPINFO));
  pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
  pbmi->bmiHeader.biWidth = nWidth;
  pbmi->bmiHeader.biHeight = -nHeight;
  pbmi->bmiHeader.biPlanes = 1;
  pbmi->bmiHeader.biBitCount = 8;
  pbmi->bmiHeader.biCompression = BI_RGB;
  pbmi->bmiHeader.biSizeImage = nWidth * nHeight;

  RGBQUAD *pColors = pbmi->bmiColors;
  for(int i = 0; i < 256; i++)
  {
    pColors->rgbBlue = i;
    pColors->rgbGreen = i;
    pColors->rgbRed = i;
    pColors->rgbReserved = 0;
    pColors++;
  }

  CWindowDC dc(NULL);
  HBITMAP hBitmap = CreateDIBitmap(dc, &pbmi->bmiHeader, CBM_INIT, pData, pbmi, DIB_RGB_COLORS);

  delete pbmi;

  return hBitmap;
}


This is for a top-down bitmap. If your image is flipped, remove the negative sign in front of the height.
GeneralRe: Creating a Bitmap from a Framegrabber Image Pin
im7910-Jul-06 21:43
im7910-Jul-06 21:43 
GeneralRe: Creating a Bitmap from a Framegrabber Image Pin
Justin Tay10-Jul-06 22:55
Justin Tay10-Jul-06 22:55 
GeneralRe: Creating a Bitmap from a Framegrabber Image Pin
im7910-Jul-06 23:12
im7910-Jul-06 23:12 
GeneralRe: Creating a Bitmap from a Framegrabber Image Pin
Justin Tay10-Jul-06 23:37
Justin Tay10-Jul-06 23:37 
GeneralRe: Creating a Bitmap from a Framegrabber Image Pin
im7911-Jul-06 1:16
im7911-Jul-06 1:16 
GeneralRe: Creating a Bitmap from a Framegrabber Image Pin
im7930-Mar-08 13:06
im7930-Mar-08 13:06 
GeneralRe: Creating a Bitmap from a Framegrabber Image Pin
Justin Tay1-Apr-08 4:09
Justin Tay1-Apr-08 4:09 
QuestionWhat is wrong with this class - C2248 error Pin
charlieg7-Jul-06 3:24
charlieg7-Jul-06 3:24 
AnswerRe: What is wrong with this class - C2248 error Pin
Taka Muraoka7-Jul-06 3:29
Taka Muraoka7-Jul-06 3:29 
GeneralRe: What is wrong with this class - C2248 error Pin
charlieg7-Jul-06 3:39
charlieg7-Jul-06 3:39 
AnswerRe: What is wrong with this class - C2248 error Pin
Chris Losinger7-Jul-06 3:32
professionalChris Losinger7-Jul-06 3:32 
Questionusing C in VC express Pin
giddy_guitarist7-Jul-06 3:23
giddy_guitarist7-Jul-06 3:23 
AnswerRe: using C in VC express Pin
Chris Losinger7-Jul-06 3:27
professionalChris Losinger7-Jul-06 3:27 
AnswerRe: using C in VC express Pin
Zac Howland7-Jul-06 3:52
Zac Howland7-Jul-06 3:52 
GeneralRe: using C in VC express Pin
giddy_guitarist31-Mar-07 5:23
giddy_guitarist31-Mar-07 5:23 
QuestionStatic method, non-static variable Pin
Daniel Kanev7-Jul-06 2:45
Daniel Kanev7-Jul-06 2:45 
AnswerRe: Static method, non-static variable Pin
RChin7-Jul-06 3:11
RChin7-Jul-06 3:11 

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.