drawBitmap() and setPixels(): what's the stride?

后端 未结 4 1716
轮回少年
轮回少年 2021-02-12 13:09

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

4条回答
  •  孤城傲影
    2021-02-12 14:03

    Stride is number of bytes used for storing one image row.

    Stride can be different from the image width.

    Most of the images are 4 byte aligned.

    For ex. a 24 bit (RGB) image with width of 50 pixels. The total bytes required will be 150 (3(RGB)*50). As image will be 4 byte aligned, in this case the byte required will become 152.

    So you will see stride as 152, width 50 and image alignment as 4 byte.

提交回复
热议问题