Bitmap color problem

I’m writing a screensaver and I’m trying to display a bitmap in the small preview window. The bitmap displays but with the wrong colours. I’ve tried offseting the pointer for the bitmap incase the problem was caused by misallignment and although this changes the colours it doesnt give me the correct colours. The bitmap is 24bit colour.

Here is the code:

HBITMAP _bmp = (HBITMAP)LoadImage(hInst, MAKEINTRESOURCE(BITMAP), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);

	BITMAP bmp;
	GetObject (_bmp, sizeof (bmp), &bmp);

	glGenTextures(1, &texture[0]);

	glPixelStorei(GL_UNPACK_ALIGNMENT,1);

	glBindTexture(GL_TEXTURE_2D, texture[0]);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);

	glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,bmp.bmWidth,bmp.bmHeight,0,GL_RGB,GL_UNSIGNED_BYTE,bmp.bmBits);
	
	DeleteObject((HGDIOBJ)_bmp);

		glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);			
		glBindTexture(GL_TEXTURE_2D, texture[0]);
		glBegin(GL_TRIANGLE_STRIP);
			
			glTexCoord2f( 0.0f, 0.0f);	glVertex3f(-10.0f, -10.0f, -50);
			glTexCoord2f( 1.0f, 0.0f);	glVertex3f(10.0f, -10.0f, -50);			


			glTexCoord2f( 0.0f, 1.0f);	glVertex3f(-10.0f, 10.0f, -50);
			glTexCoord2f( 1.0f, 1.0f);	glVertex3f(10.0f, 10.0f, -50);
		
		glEnd();

Apologies if the answer is to do with MSVC and not OpenGL.

Thanks.

btw there is a good reason for me just displaying a bitmap and not the screensaver itself in the preview window.

I think you are loading a BGR image and telling OpenGL it is RGB. Either use GL_EXT_BGR, if available, or simply swap the red and blue channels.

Yep, youre right thanks