CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Help in bitmap

  1. #1
    Join Date
    Feb 2004
    Posts
    1

    Help in bitmap

    Hi,

    I am aware that bitmap object consists of 4 parts: BITMAPFILEHEADER, BITMAPINFOHEADER, color platette and the pixel data. Can anyone tell me how to extraxt only the pixel data from bitmap object and put it inside a char array or byte array?

    Hope someone could help me. Thank you.

  2. #2
    Join Date
    Jan 2004
    Location
    Earth
    Posts
    567
    Hi,

    I think the GetDIBits may work. Below is a link to MSDN for GetDIBits.

    GetDIBits

    TDM
    Last edited by TDM; February 26th, 2004 at 11:39 PM.

  3. #3
    Join Date
    Feb 2004
    Posts
    8
    Hi,

    I am also interested in finding out about extracting pixel data from bitmap object..but have little knowledge of Visual C++. Is there any sample code on using the GetDIBits to refer to?

    Btw, i've make some research and found out that LockBits method might also work in extracting pixel data from bitmap object. Is it true?

    Thks a lot!!!!!

  4. #4
    Join Date
    Nov 2002
    Location
    Israel
    Posts
    182
    I think you're talking about GetBitmapBits function.

    Example:
    BITMAP bitmap = { 0 };
    ::GetObject(hBitmap, sizeof(BITMAP), &bitmap);

    int nSize = ((((bitmap.bmWidth * bitmap.bmBitsPixel) + 31) & ~31) >> 3) * bitmap.bmHeight;

    void* pBuffer = malloc(nSize);
    memset(pBuffer, 0, nSize);

    ::GetBitmapBits(hBitmap, nSize, pBuffer);

    I'll be glad to find something like this for WinCE.
    Good luck

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured