PDA

View Full Version : How to load 30 BMP frames to device ?



michpre
07-24-2012, 01:40 AM
Hey

I would like to load about 30 BMP frames (30 layers of one image) to device
and then merge the layers to one image .
I would like to do that (only the merging) with openGL (in order to get better perfomance)
I dont want to display the image only the merging and then back the image to save on disk.
Any idea how to do that?

Thanks
Miki

thokra
07-24-2012, 03:50 AM
Well, the brute-force way would be to load either load your pixels into 30 texture objects and then render correctly sized quads and do some blending operation either with a shader or with fixed blending ops and then read the resulting data back to the application with glReadPixels(). Note that this definitely not the only way to do it, but it's the most simple way IMHO. The problem I see here is that you don't define what merging means in your context.
Please be more specific.

michpre
07-24-2012, 04:28 AM
Thanks

to be more specific
I run over the layer
for (...each layer...){
for (...image Width...){
for (....image Height...)
{
ouputImage += F(x,y,Layer) ///where F is some function that "merge the pixel for for all layers to one outputImage"
}
}
}

since I m Newbie to openGL can you also give the basic gl functions (best prototype) of how to do that?

Thanks much
Miki

thokra
07-24-2012, 04:54 AM
The question remains: what is F? Do you want addition, multiplication, difference? Pick one and I'll try to give you an example.

The rest is fairly basic and not a problem at all.

michpre
07-24-2012, 05:17 AM
Thanks

F chose the visible pixel from the all layers and put it in ouput image (here rgmb_main_raster is output image)
rgb_main_raster[i]=rgb_main_raster[i]*(1-alpha)+layer_rgb[i]*alpha+k;

Miki

thokra
07-24-2012, 06:00 AM
How do you determine alpha? Is is a fixed value? Is it supposed to be determined and stored per pixel? What is k?

michpre
07-24-2012, 06:22 AM
k is constant 0.5
alpha is per pixel