开发者

ArcObjects: saving IRaster with double values mapped to colors

开发者 https://www.devze.com 2023-01-23 15:20 出处:网络
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.Figur

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");
0

精彩评论

暂无评论...
验证码 换一张
取 消