How do you save IRaster with double values in it's cells mapped to some colors? For example, (-inf; -50] maps to blue, [+50; +inf) maps to yellow, ot开发者_运维百科hers are calculated gradually.
Figured out: you have to make one raster for each band (red, green and blue) with values in range [0; 255] (values in each cell will be combined using RGB color model). Then those rasters should be combined into one through IBandCollection. Code below illustrates:
// Create three rasters
IRaster2 redRaster = ...;
IRaster2 greenRaster = ...;
IRaster2 blueRaster = ...;
// Combine them
IRasterBandCollection bands = (IRasterBandCollection)redRaster; // bands are appended to the red raster
bands.AppendBand(((IRasterBandCollection)greenRaster).Item(0));
bands.AppendBand(((IRasterBandCollection)blueRaster).Item(0));
// Save as JPEG
IWorkspace saveWorkspace = ...;
String fileName = ...;
((ISaveAs2)redRaster).SaveAs(fileName, saveWorkspace, "JPG");
精彩评论