Converting DPX and EXR to RGB in C++
Posted: 2010-05-27T03:29:44-07:00
I've compiled Imagemagick 6.6.1 with HDRI and exr enabled.
I'm also developing my application with generated DLLs for converting image formats.
Now I encounter a problem converting DPX and EXR to BMP.
For EXR files, my C++ codes are as follows:
After writing the rgb buffer to a bmp file, the content is a mess.
How do I retrieve the pixels in RGB from exr file? I think I can set the color depth (e.g. RGB888) but I don't know how.
Please help...
For DPX files, the codes to convert DPX to BMP are exactly the same as above, the except the file name is "my_image.dpx".
However, the output bmp file looks like the red and blue are swapped. I have to swapped red and blue in codes to make it right.
Please also advise what is going wrong.
Thank you!
I'm also developing my application with generated DLLs for converting image formats.
Now I encounter a problem converting DPX and EXR to BMP.
For EXR files, my C++ codes are as follows:
Code: Select all
try {
src_image.read("image.exr");
width = src_image.columns();
height = src_image.rows();
}catch( Exception &error_ ) //not an image file
{
continue;
}
src_image.modifyImage();
src_image.type(TrueColorType);
src_image.gamma(2.2);
pixel = src_image.getPixels(0,0,width,height);
for(int y=0; y<height; y++)
{
for(int x=0; x<width; x++)
{
PixelPacket *pixel_rgb = pixel + y*width+x;
input_rgb[y*width*3 + 3*x + 0] = (pixel_rgb->blue); //B
input_rgb[y*width*3 + 3*x + 1] = (pixel_rgb->green); //G
input_rgb[y*width*3 + 3*x + 2] = (pixel_rgb->red); //R
}
}
How do I retrieve the pixels in RGB from exr file? I think I can set the color depth (e.g. RGB888) but I don't know how.
Please help...
For DPX files, the codes to convert DPX to BMP are exactly the same as above, the except the file name is "my_image.dpx".
However, the output bmp file looks like the red and blue are swapped. I have to swapped red and blue in codes to make it right.
Please also advise what is going wrong.
Thank you!