/// <summary> /// this method writes values to the current block of pixels of the raster /// </summary> /// <param name="pixelblock3">current block of pixels</param> protected override void DoOperationsWithPixels(IPixelBlock3 pixelblock3) { //Get the pixel array. pixels = (System.Array)pixelblock3.get_PixelData(0); blockwidth = pixelblock3.Width; blockheight = pixelblock3.Height; pixelblock3.Mask(255); object k = null; //iterate through each line in an image for (int i = 0; i < blockwidth; i++) { //iterate through each pixel in the line for (int j = 0; j < blockheight; j++) { k = Convert.ToSingle(blocksWithValues[numOfBlock, i + j * 64]); pixels.SetValue(k, i, j); } } //Set the pixel array to the pixel block. pixelblock3.set_PixelData(0, pixels); //Write back to the raster. tlc = rasterCursor.TopLeft; rasterEdit.Write(tlc, (IPixelBlock)pixelblock3); }
/// <summary> /// this method reads values from the current block of pixels of the raster /// </summary> /// <param name="pixelblock3">current block of pixels</param> protected override void DoOperationsWithPixels(IPixelBlock3 pixelblock3) { blockwidth = pixelblock3.Width; blockheight = pixelblock3.Height; pixelblock3.Mask(255); //Get the pixel array. pixels = (System.Array)pixelblock3.get_PixelData(0); //iterate through each line in an image for (long i = 0; i < blockwidth; i++) { //iterate through each pixel in the line for (long j = 0; j < blockheight; j++) { double val; //Get the pixel value v = pixels.GetValue(i, j); val = Convert.ToDouble(v.ToString()); if (val > 240) { val = 0; //if value is higher than 240, then value is probaly incorrect } //write pixel value to the array allBlocks[numOfBlock, i + j * 64] = val; } } }