• Advertisement

Archived

This topic is now archived and is closed to further replies.

Creeating a HBITMAP from glReadPixels

This topic is 4977 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok for the life of me I cant figure out how to make a HBITMAP from what is in my gl window. I've been triing with varations of the following code, the glReadPixels works fine, but the matter of making the HBITMAP has me stumped

HBITMAP Exporter::GetHBitmap(int Width, int Height, int Offset)
{
	void *image = new BYTE[Width*Height*3];
	if( image!=NULL )
	{
		glReadPixels( 0, Offset, Width, Height, GL_BGR_EXT, GL_UNSIGNED_BYTE, image );
		HBITMAP hBitmap;
		hBitmap = CreateBitmap(Width,Height,3,24,image);
		delete[] image;
		return hBitmap;
	}
}
Thanks for any help [edited by - skow on June 8, 2004 1:28:45 PM] [edited by - skow on June 8, 2004 1:41:32 PM]

Share this post


Link to post
Share on other sites
Advertisement
your call to createbitmap is wrong, that 8 should be a 3 for the number of color planes, also as i recall the format needed is BGR for Windows Bitmaps, so unless you''ve got a BGR context you''ll need to perform some rearragement on the data...

CreateBitMap

Share this post


Link to post
Share on other sites
Opps, yeah I do have 3 in there, and its not working. Had 8 in there from when i was triing other stuff

I''m using GL_BGR_EXT, so the order should be right, reguardless, even if the order is wrong it should still create bitmap just with the color channels being mixed.

The CreateBitmap returns NULL except when I pass in 1 for the cPlanes, but that doesn''t end up giving me a working HBITMAP.

Share this post


Link to post
Share on other sites

  • Advertisement