“recode” Pixel Buffer Object into Windows bitmap?

Hi!
I’m a Java guy , my C++ is very rusty, but this is on my plate.
How can I “transcode” the contents of a Pixel Buffer Object (PBO) to a Windows bitmap? The kind that has an HBITMAP handle?

We are working with Nvidia’s CUDA, and we have inherited some existing code. In it, the GPU has worked its parallel magic on a PBO. The existing code uses GLUT to show the PBO on a window on the display. We need to get rid of the display and the window, and recode the PBO into a Windows bitmap. In case you are wondering, the windows bitmap will be converted into a PNG, but the plan right now is that will be done inside a Java application server via BufferedImage.

What I’m looking for right now is a library function, or technique that will take a PBO, and creates a bitmap. Extra good would be if the function created anything that’s easy to convert into a PNG or a java.awt.image.BufferedImage :wink:

Can anyone help?

Thanks!

I’ll start this by saying I’m not a Windows person, so I don’t actually know what an HBITMAP is, but I have worked with bitmap files before.

You could use glReadPixels to get the raw data from the PBO or the display. Using that, you can write your own bitmap file, or create a DataBuffer/Raster/BufferedImage (you can read the docs just as well as I can) directly from that data.
This page, gives a brief description of the bmp format, and some C source code, which may or may not be useful.

nVidia SDK9, TexturePerformancePBO example: on how to setup a fast glReadPixels to RAM.

You should use a DIB. Make it 32bpp. A DIB’s handle is a HBITMAP. GDI+ and etc can compress this image into PNG.

Whatever the way, glReadPixels is the start.

Thanks for the info!
I’ll research glReadPixels, DIB and GDI+