Link to home
Start Free TrialLog in
Avatar of Paladin_VB
Paladin_VB

asked on

Loading Bitmap into GLubyte Array

Please could someone show me or provide me with the source code to load a bitmap into a GLubyte Array

So the actual bitmap image is in GLubyte[] , so I can edited it .

I am trying to make a game with destructable terrain which can be loaded from bitmaps :) . Any other hints on how to edit it in realtime , would be useful .

Ps. as you obviously have worked out I am using OpenGL .

Lots of thanks in advance,

Paladin
Avatar of jkr
jkr
Flag of Germany image

Check out http://support.microsoft.com/default.aspx?scid=kb;en-us;158898 ("HOWTO: How To Use LoadImage() to Read a BMP File"). The idea is to

  // Use LoadImage() to get the image loaded into a DIBSection
   HBITMAP hBitmap = (HBITMAP)LoadImage( NULL, szFileName, IMAGE_BITMAP, 0, 0,
               LR_CREATEDIBSECTION | LR_DEFAULTSIZE | LR_LOADFROMFILE );

  GLubyte ab [MAX_SIZE]; // size should be the size of the .bmp file

  GetBitmapBits(hBitmap,MAX_SIZE, (LPVOID) ab);
Avatar of Paladin_VB
Paladin_VB

ASKER

So how do i find the size of the bitmap ?

point boost 25 :P
Oh, that's easy, e.g.

#include <sys/types.h>
#include <sys/stat.h>

struct _stat st;

_stat("c:\\tmp\\myfile.bmp",&st);

DWORD dwSize = st.st_size;
Wowh that was fast !!!! Thanks :)
How do i find the value which should be put in MAX_SIZE ? and how do i find the dimensions of the bitmap ??

+20 :P
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial