Hi everyone in ESRI community!
I have an code below utilized IPixelBlock3. however it was an older ESRI 9.3 version i believe. I do not know why the pixel block in the final array does not take set value any other than SByte. But my data needs to be Byte. The legitimate range of my pixel values extends outside the range of sbyte . It seems like something upstream in how pixeldata0 is declared or initialized from pblock_03, that passed to the setvalue call are causing it to only want an sbyte. i Do not know if IPixelBlock3 got changed in ESRI 10.5 version. the code are as below if any body can help to see and help me out?
the error is happening at the end of the scripts where i have comments.
```
System.Array pixelDatao;
DateTime dt1 = DateTime.Now;
tspre = dt1 - dt0;
for (int jtile = 0; jtile < nytiles; jtile++)
{
for (int itile = 0; itile < nxtiles; itile++)
{
if ((ytile * (jtile + 1) > yoff1) && (ytile * jtile < (nrowo - yoff2)))
{
if ((xtile * (itile + 1) > xoff1) && (xtile * itile < (ncolo - xoff2)))
{
DateTime dt00 = DateTime.Now;
int xpt = itile * xtile;
int ypt = jtile * ytile;
tlco.SetCoords(xpt, ypt);
rRastero.Read(tlco, pBlocko);
IPixelBlock3 pBlocko_3 = (IPixelBlock3)pBlocko;
pixelDatao = (System.Array)pBlocko_3.get_PixelDataByRef(0);
int xpt2 = xtile * itile - xoff1;
int ypt2 = ytile * jtile - yoff1;
if (ypt2 < 0) ypt2 = 0;
if (xpt2 < 0) xpt2 = 0;
tlc2.SetCoords(xpt2, ypt2);
rRaster2.Read(tlc2, pBlock2);
IPixelBlock3 pBlock2_3 = (IPixelBlock3)pBlock2;
DateTime dt01 = DateTime.Now;
tsread = tsread + (dt01 - dt00);
for (int y = 0; y < pBlocko_3.Height; y++)
{
for (int x = 0; x < pBlocko_3.Width; x++)
{
object oval1 = pBlocko_3.GetVal(0, x, y);
object oval2 = pBlock2_3.GetVal(0, x, y);
object oval3 = null;
if (oval1 != null)
{
if (xpt + x >= xoff1 && xpt + x < ncolo - xoff2 &&
ypt + y >= yoff1 && ypt + y < nrowo - yoff2)
{
int x2 = xpt + x - xoff1 - xpt2;
int y2 = ypt + y - yoff1 - ypt2;
if (oval2 != null)
{
int val1 = Convert.ToByte(oval1);
int val2 = Convert.ToByte(oval2);
int val3 = accval[val2] + val1;
oval3 = Convert.ToByte(val3);
pixelDatao.SetValue(oval3, x, y);
}
}
}
}
pBlocko_3.set_PixelData(0, pixelDatao);
DateTime dt02 = DateTime.Now;
tsup = tsup + (dt02 - dt01);
rRastero.Write(tlco, (IPixelBlock)pBlocko_3);
DateTime dt03 = DateTime.Now;
tswrite = tswrite + (dt03 - dt02);
```