AnsweredAssumed Answered

How to set some rgb transparent

Question asked by geonetadmin on Dec 25, 2013
Latest reply on Jan 3, 2014 by geonetadmin
Original User: 674438511

Hi!

I'm looking for a code in c# that take a rasterlayer (.tif) and display it in my globecontrol with transparency where is some specific rgb,such as R0 G0 B0. I know i can add it to my globecontrol with this code

//////////
IRasterDataset pRasterdataset = pRasterworkspace.OpenRasterDataset(filename);   

IRaster pRaster = pRasterdataset.CreateDefaultRaster();
IRasterLayer pRasterlayer = new RasterLayerClass();
pRasterlayer.CreateFromRaster(pRaster);
ILayer pLayer = pRasterlayer as ILayer;
axGlobeControl1.Globe.AddLayerType(pLayer, esriGlobeLayerTypeFloating, false);
//////////

But how can i change some specific rgb(such as R0 G0 B0) of raster to transparency?

My guess:
///////
IRasterDataset pRasterdataset = pRasterworkspace.OpenRasterDataset(filename);
IRasterBandCollection rasterBands = (IRasterBandCollection)pRasterdataset;
IRasterBand rasterBand;
IRasterProps rasterProps;
           
rasterBand = rasterBands.Item(0);//band R
rasterProps = (IRasterProps)rasterBand;//now�?NoDataValue = 256 default value
rasterProps.NoDataValue = 0;
rasterBand = rasterBands.Item(1);//band G
rasterProps = (IRasterProps)rasterBand;//now�?NoDataValue = 256 default value
rasterProps.NoDataValue = 0;
rasterBand = rasterBands.Item(2);//band B
rasterProps = (IRasterProps)rasterBand;//now�?NoDataValue = 256 default value
rasterProps.NoDataValue = 0;

IRaster pRaster = pRasterdataset.CreateDefaultRaster();
IRasterProps propt = (IRasterProps)pRaster;//now�?NoDataValue = 0
IRasterLayer pRasterlayer = new RasterLayerClass();
pRasterlayer.CreateFromRaster(pRaster);
ILayer pLayer = pRasterlayer as ILayer;
axGlobeControl1.Globe.AddLayerType(pLayer, esriGlobeLayerTypeFloating, false);
///////

But, it doesn�??t work!

Now display�?(have black region)
[ATTACH=CONFIG]30108[/ATTACH]

I want�?(do not show black region)(yellow region is earth map)
[ATTACH=CONFIG]30109[/ATTACH]


Thanks

Attachments

Outcomes