Could please somebody explain me (ASCII is really welcome) what the stride
argument stands for in Canvas.drawBitmap() and in Bitmap.setPixels()/getPixels()? I under
I suppose the question is about Android, java, not windows! In this case, stride has nothing to do with "number of bytes used for storing one image row", that is a windows nomenclature.
Before you understand the parameter "stride", you need to know that getPixels is a function copying pixels from the source Bitmap to destination array ( which is typed int Pixels[]).
concerning copying, you need to know where is the source (to come from), and where is the destination (to come to), in function,
public void getPixels(int[] pixels, int offset, int stride, int x, int y, int width, int height) {
throw new RuntimeException("Stub!");
}
these 4 parameters control the source: int x, int y, int width, int height
these 3 parameters control the destination: int[] pixels, int offset, int stride
e.g. You have a sourceImage with width*height = 100*100Pixels, you make a destinationImage with width*height = 200*100Pixels,and You make the following codes,
sourceImage.getPixels(pixels, 0, 2*wd, 0, 0, wd, ht); // No.1 copying
sourceImage.getPixels(pixels, wd, 2*wd, 0, 0, wd, ht);// No.2 copying
destinationImage = Bitmap.createBitmap(pixels, 0, 2*wd, 2*wd, ht, Bitmap.Config.ARGB_8888); // make a big image twice the size of the original
Explanation is given as follows for No.1 copying getPixels,
1 line reading: with line width = wd, and put it into Pixels[0]~Pixels[wd-1];
2 line reading: put it into Pixels[stride+0]~Pixels[stride+wd-1];
nth line reading: put it into Pixels[(n-1)*stride]~Pixels[(n-1)*stride+wd-1].
That is pretty much of the getPixels.