You can use stride = pixel_size * image_width value. For example, for RGBA bitmap with 100 pixel width, stride = 400.
Some applications may require special line alignment. For example, Windows GDI bitmaps require 32-bits line alignment. In this case, for RGB bitmap with width = 33, stride value 33*3=99 should be changed to 100, to have 32-bits line alignment in destination array.
Generally, you should know destination array requirements. In there are no special requirements, use default pixel_size * image_width.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…