Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pixel by pixel bitmap drawing (like landscape in worms)

6 views
Skip to first unread message

matthew.green5

unread,
Jul 3, 2002, 5:30:47 PM7/3/02
to
Can anybody please tell me if it is possible to extract single pixels from a
bitmap file (in windows 98se, if that's relavent) to draw on the screen,
allowing for a worms type landscapes and if so how this would be done?


anderson

unread,
Jul 3, 2002, 10:47:12 PM7/3/02
to
If your using visual C++ it's incredably easy as the bitmap headers are
built in.

The bitmap header (in wingdi.h)

typedef struct tagBITMAPFILEHEADER
{
WORD bfType;
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
} BITMAPFILEHEADER;

//Normally comes next
typedef struct BITMAPINFOHEADER
{
DWORD biSize;
LONG biWidth; //Width
LONG biHeight; //Height
WORD biPlanes;
WORD biBitCount; // Colour resolution ( 16 = 16 bit, 24 = 24 bit )
DWORD biCompression; // Type of compression used
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER;

Your going to have to do a bit more research on the BMP formats to work out
the differn't types of compression methods with the differn't amount of
colours.

Anyway one format, 24 bit with compression = BI_RGB (no compression) is very
easy. Following the header there's just a list of 3 bytes (RGB) for each
pixel in the map. So thats 3 x biWidth x biHeight.

Anyway there's no way to extract a single pixel without reading alot of the
header stuff in the BMP.

Note that this is an openGL newgroup and this question doesn't seem to
related. You should use comp.graphics.api.algorithms for graphics only
related questions.

"matthew.green5" <matthew...@ntlworld.com> wrote in message
news:D_JU8.346$wo5....@newsfep2-win.server.ntli.net...

matthew.green5

unread,
Jul 4, 2002, 5:27:50 PM7/4/02
to

> Note that this is an openGL newgroup and this question doesn't seem to
> related. You should use comp.graphics.api.algorithms for graphics only
> related questions.

I wasn't to sure about this. I'm using opengl, and the instructions for
loading and displaying bitmaps were in the book 'Opengl Game Programming'.
I wasn't sure if the load bitmap stuff was opengl specific or general win32.
It is within the bounds of opengl that I wish to use this.


anderson

unread,
Jul 4, 2002, 11:15:27 PM7/4/02
to
"matthew.green5" <matthew...@ntlworld.com> wrote in message
news:R13V8.1763$xf3.5...@news11-gui.server.ntli.net...

>
> I wasn't to sure about this. I'm using opengl, and the instructions for
> loading and displaying bitmaps were in the book 'Opengl Game Programming'.
> I wasn't sure if the load bitmap stuff was opengl specific or general
win32.
> It is within the bounds of opengl that I wish to use this.
>
>

Then if your loading a BMP to a texture use glTexImage2D and simply put the
24-bit map in with the parms.

void glTexImage2D( GL_TEXTURE_2D, 1, 3, Width, Height, 0, GL_RGB, GL_BYTE,
pixelsArray );

Should do it. Note also you need all the other texturing code that should be
in that book.

If you want to draw directly to the screen use glDrawPixels.


0 new messages