Пробую программно изменить значения пикселей. Но что-то не получается. Использую при этом вот такой вот код(чужой):
IDocument ipDoc = m_application.Document;
IMxDocument ipMxDoc = ipDoc as IMxDocument;
IMap ipMap;
ipMap = ipMxDoc.FocusMap as IMap;
int layerCount;
layerCount = ipMap.LayerCount;
ILayer Layer;
Layer = ipMap.get_Layer(0);
IRasterLayer Rasterlayer;
Rasterlayer = Layer as IRasterLayer;
String Filepath = Rasterlayer.FilePath;
//1.open a raster data(*.BMP)file
IRasterWorkspace pOrgWs; //input raster workspace
IWorkspaceFactory pWsFact; //workspace factory
IRasterDataset pOrgRasterDs; // input raster dataset
IRasterBandCollection pOrgBands;//input rasterband collection
IRasterProps pRasProp; // input raster properties
String sInputName;
IPoint pPoint;
IRaster pOrgRaster;
IPixelBlock pOrgPixel; //input raster pixelblock
//Trim the filepath and filename
sInputName = Filepath.Trim();
String sPath, sName;
int iPos = sInputName.LastIndexOf('\\');
if (iPos > 0)
{
sName = sInputName.Substring(iPos + 1);
//MessageBox.Show("filename : "+sName);
sPath = sInputName;
int namelen = sName.Length;
int totallen = sInputName.Length;
int pathlen = totallen - namelen;
sPath = sInputName.Substring(0, pathlen);
//MessageBox.Show("Pathname : "+sPath);
}
else
{
sName = sInputName;
sPath = sInputName;
}
//Open input workspace
pWsFact = new RasterWorkspaceFactory();
pOrgWs = pWsFact.OpenFromFile(sPath, 0) as IRasterWorkspace;
//Open input raster dataset and get properties
pOrgRasterDs = pOrgWs.OpenRasterDataset(sName);
pOrgRaster = pOrgRasterDs.CreateDefaultRaster();
//Get the three bands invovled in Raster dataset.
pOrgBands = pOrgRasterDs as IRasterBandCollection;
pRasProp = pOrgBands.Item(0) as IRasterProps;
IPnt pSize = new PntClass();
pSize.SetCoords(pRasProp.Width, pRasProp.Height);
IPnt pPnt = new PntClass();
pPnt.SetCoords(0, 0);
//2.Associate the 3 Rasrter Bands to respective Rawpixel interface by querying.
IRasterBand Band1 = pOrgBands.Item(0);
IRawPixels pRawPixel1 = Band1 as IRawPixels;
pRawPixel1 = (IRawPixels)Band1;
//Get the pixel block from each rawpixel.
IPixelBlock pixel1;
pixel1 = pRawPixel1.CreatePixelBlock(pSize);
//3.Get the pixelblock values in safearray.
System.Array array1;
array1 = pixel1.get_SafeArray(0) as System.Array;
for (int i = 0; i < pixel1.Height; i++)
&nbs