I do not know how you initialize rgbArray , but each line ends with a black pixel (outside the image). It can represent a new line if you initialized rgbArray by reading bytes directly from the image file. Or you did not properly initialize rgbArray .
Black pixels are displayed on the shift image as a diagonal line.
You can skip the black pixels at the end of each line by changing this:
bi.setRGB(0, 0, width, height, rgbIntArray, 0, width);
:
bi.setRGB(0, 0, width, height, rgbIntArray, 0, width + 1);
The last parameter, width + 1 , basically says that if a given row starts at a specific index in the array, the next row starts at an index that width + 1 higher in the same array.
source share