来自:http://zhihu.esrichina.com.cn/?/question/6725

【解决办法】:
可以通过设置背景值以及背景色解决此问题。
对于三波段进行RDB渲染的影像可以使用下面代码:
IRasterRenderer RR = RL.Renderer; 
IRasterRGBRenderer rasterRGBRenderer = null; 
if (RR is IRasterRGBRenderer) 
rasterRGBRenderer = RR as IRasterRGBRenderer; 
RR.Update(); 
rasterRGBRenderer.RedBandIndex = 0; 
rasterRGBRenderer.GreenBandIndex = 1; 
rasterRGBRenderer.BlueBandIndex = 2; 
IRgbColor rgb = new RgbColorClass(); 
rgb.NullColor = true; 
IRasterStretch2 RS = rasterRGBRenderer as IRasterStretch2; // IRasterStretch无法设置数组,需用2 
double background = 
{ 
0, 0, 0 
}; 
RS.Background = true; 
RS.BackgroundValue = background as object; 
RS.BackgroundColor = rgb as IColor; 
axMapControl1.Refresh();


对于单波段影像: 
单波段:
IRasterRenderer RR = RL.Renderer;
IRasterStretchColorRampRenderer RSC = null;
if (RR is IRasterStretchColorRampRenderer)
RSC = RR as IRasterStretchColorRampRenderer;
RR.Update();
RSC.BandIndex = 0;
IRgbColor rgb = new RgbColorClass(); 
rgb.NullColor = true; 
IRasterStretch RS = RSC as IRasterStretch;
RS.Background = true;
RS.set_BackgroundValues(0);
RS.BackgroundColor = rgb as IColor;
axMapControl1.Refresh();

相关文章: