문제

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, others 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");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top