let's just say I want to have a SOP that dumps an exr file.
Maybe it's, say, 1024 by 512, with 2 float image planes, and an 8-bit RGB image plane, maybe.
UT_Raster won't work.
IMG_Plane looks like it'll handle each plane, but, how do I wrap ‘em up and dump ’em to an exr?
HDK EXR writing
1837 2 1- ivan
- Member
- 83 posts
- Joined: July 2005
- Offline
- symek
- Member
- 1390 posts
- Joined: July 2005
- Offline
- ivan
- Member
- 83 posts
- Joined: July 2005
- Offline
thanks Symek! that got my toe in the door.
this is a bit verbose, but…. this works, if anybody needs to do this.
one odd thing- I cannot get a valid PXL_Raster with a PXL_FLOAT32 format and PACK_RGB packing. ? why? I do not know.
(I made use of UT_RGBA, obviously that will only work for C_Raster)
—————————————————————————-
IMG_Stat myStat;
myStat.setResolution(xres,yres);
myStat.addDefaultPlane();
myStat.addPlane(“inty”,IMG_INT32,IMG_1CHAN);
myStat.addPlane(“Norm”,IMG_FLOAT16,IMG_RGB);
myStat.addPlane(“small”,IMG_INT8,IMG_1CHAN);
IMG_File *newImg = IMG_File::create(“NEWFOO.pic”,myStat);
PXL_Raster C_Raster, inty_Raster, N_Raster, small_Raster;
C_Raster.setFormat(PXL_INT8);
C_Raster.setPacking(PACK_RGBA);
C_Raster.setRes(xres,yres);
C_Raster.init();
inty_Raster.setFormat(PXL_INT32);
inty_Raster.setPacking(PACK_SINGLE);
inty_Raster.setRes(xres,yres);
inty_Raster.init();
//N_Raster.setFormat(PXL_FLOAT32);
N_Raster.setFormat(PXL_FLOAT16);
N_Raster.setPacking(PACK_RGB);
N_Raster.setRes(xres,yres);
N_Raster.init();
small_Raster.setFormat(PXL_INT8);
small_Raster.setPacking(PACK_SINGLE);
small_Raster.setRes(xres,yres);
small_Raster.init();
cout <<“valid: ”<<C_Raster.isValid()<<address_Raster.isValid()<<loc_Raster.isValid();
cout <<N_Raster.isValid()<<type_Raster.isValid()<<endl;
UT_RGBA *CPixels = (UT_RGBA*)C_Raster.getPixels();
for (int x = 0; x < xres; x++)
{
for (int y = 0; y < yres; y++, CPixels++)
{
if(y<(yres*.5)){
CPixels->r = 100;
CPixels->g = 0;
CPixels->b = 100;
}else{
CPixels->r = 0;
CPixels->g = 100;
CPixels->b = 0;
}
}
}
UT_ValArray <PXL_Raster*> rasters;
rasters.append(&C_Raster);
rasters.append(&inty_Raster);
rasters.append(&N_Raster);
rasters.append(&small_Raster);
newImg->writeImages(rasters);
this is a bit verbose, but…. this works, if anybody needs to do this.
one odd thing- I cannot get a valid PXL_Raster with a PXL_FLOAT32 format and PACK_RGB packing. ? why? I do not know.
(I made use of UT_RGBA, obviously that will only work for C_Raster)
—————————————————————————-
IMG_Stat myStat;
myStat.setResolution(xres,yres);
myStat.addDefaultPlane();
myStat.addPlane(“inty”,IMG_INT32,IMG_1CHAN);
myStat.addPlane(“Norm”,IMG_FLOAT16,IMG_RGB);
myStat.addPlane(“small”,IMG_INT8,IMG_1CHAN);
IMG_File *newImg = IMG_File::create(“NEWFOO.pic”,myStat);
PXL_Raster C_Raster, inty_Raster, N_Raster, small_Raster;
C_Raster.setFormat(PXL_INT8);
C_Raster.setPacking(PACK_RGBA);
C_Raster.setRes(xres,yres);
C_Raster.init();
inty_Raster.setFormat(PXL_INT32);
inty_Raster.setPacking(PACK_SINGLE);
inty_Raster.setRes(xres,yres);
inty_Raster.init();
//N_Raster.setFormat(PXL_FLOAT32);
N_Raster.setFormat(PXL_FLOAT16);
N_Raster.setPacking(PACK_RGB);
N_Raster.setRes(xres,yres);
N_Raster.init();
small_Raster.setFormat(PXL_INT8);
small_Raster.setPacking(PACK_SINGLE);
small_Raster.setRes(xres,yres);
small_Raster.init();
cout <<“valid: ”<<C_Raster.isValid()<<address_Raster.isValid()<<loc_Raster.isValid();
cout <<N_Raster.isValid()<<type_Raster.isValid()<<endl;
UT_RGBA *CPixels = (UT_RGBA*)C_Raster.getPixels();
for (int x = 0; x < xres; x++)
{
for (int y = 0; y < yres; y++, CPixels++)
{
if(y<(yres*.5)){
CPixels->r = 100;
CPixels->g = 0;
CPixels->b = 100;
}else{
CPixels->r = 0;
CPixels->g = 100;
CPixels->b = 0;
}
}
}
UT_ValArray <PXL_Raster*> rasters;
rasters.append(&C_Raster);
rasters.append(&inty_Raster);
rasters.append(&N_Raster);
rasters.append(&small_Raster);
newImg->writeImages(rasters);
-
- Quick Links