Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Loading bitmap into Gluint [256 * 256] array

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2000
    Location
    OKC, OK, USA
    Posts
    8

    Loading bitmap into Gluint [256 * 256] array

    I'm trying to load a bitmap into a 256 x 256 array. I have currently loaded the bitmap into the Visual c++ project as a binary. Do I use the HBITMAP class and some how get a pointer to the binary and iterate it into the array. This is very complicated to me and would like a good example.

    Chad
    Chad Schmidt

  2. #2
    Intern Contributor
    Join Date
    Feb 2000
    Location
    Germany
    Posts
    95

    Re: Loading bitmap into Gluint [256 * 256] array

    Well, I don't have a compiler right here, but the following lines should give you a hint at least.
    The function GetDIBits is used for retrieving the raw pixel data from a windows bitmap. All you need is a HDC and a HBITMAP handle

    Code :
    GLubyte pointer_to_your_array[256*256*3];
    // 1. prepare BITMAPINFOHEADER for GetDIBits
    BITMAPINFOHEADER info;
    info.biSize=sizeof(BITMAPINFOHEADER); 
    info.biWidth=256;
    info.biHeight=-256; // we usually want a top-down-bitmap
    info.biPlanes=1;
    info.biBitCount=24;
    info.biCompression=BI_RGB;
    info.biSizeImage=0;
    info.biXPelsPerMeter=10000; // just some value
    info.biYPelsPerMeter=10000; // just some value
    info.biClrUsed=0;
    info.biClrImportant=0;
    // 2. let's do it
    GetDIBits(hdc,
              hbitmap,
              0,
              256,
              (void*)pointer_to_your_array,
              (BITMAPINFO*)&info,
              DIB_RGB_COLORS);
    // 3. Now your array should contain the raw bitmap data
    The pointer you've got to supply must point to an array at least 256*256*3 bytes large (*3, cause in the example above you want retrieve RGB data, so 3 byte per pixel are necessary).
    Hope it helped (and hope it works - can't test it).

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2000
    Location
    OKC, OK, USA
    Posts
    8

    Re: Loading bitmap into Gluint [256 * 256] array

    thanks for the help I got it working!
    Chad Schmidt

Posting Permissions

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