any can explain the function of stride in bitmapdata?

后端 未结 5 429
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-01 11:25
        Bitmap bit1 = new Bitmap( bmpimg , width , height );
        Bitmap bit2 = new Bitmap( bmp , width , height );

        Bitmap bmpresult = new Bitmap( width          


        
5条回答
  •  天命终不由人
    2020-12-01 12:17

    Yes, it's necessary.

    The stride value is the offset from the start of one scan line to the start of the next scan line. If the scan lines are padded, the value is a few bytes more than what's needed for the pixels in the scan line.

    If the bitmap is stored upside down in memory (i.e. the bottom scan line first), the stride value is negative. If you would read such a bitmap without using the stride value, you would get just garbage after the first scan line, or a memory access error.

提交回复
热议问题