This documentation is for the old version. Go to the latest Graphics Mill docs

BitmapData.Stride Property

Returns the bitmap data stride (scan line width in bytes).

Namespace: Aurigma.GraphicsMill
Assembly: Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)

Syntax

Visual Basic
Public ReadOnly Property Stride As Integer
C#
public int Stride { get; }

Property Value

Scan line width in bytes.

Remarks

Since Width property specifies number of pixels in single scan line, this property contains number of bytes in a scan line. As scan line may be aligned on four-bytes boundary, stride may differ from bitmap data width multiplied on number of bytes per pixel. That's why you should use this property to move to the same position on the next row instead of any other methods.

Examples

C#
Aurigma.GraphicsMill.BitmapData bitmapData = bitmap.LockBits();

unsafe
{
    byte* pos;
    byte* scan0 = (byte*)(bitmapData.Scan0.ToPointer());
    int stride = bitmapData.Stride;

    int widthInBytes = bitmapData.Width * bitmapData.BitsPerPixel / 8;
    int height = bitmapData.Height;

    for (int j = 0; j < height; j++)
    {
        pos = scan0 + stride * j;
        for (int i = 0; i < widthInBytes; i++)
        {
            *pos = (byte)(255 - *pos);
            pos++;
        }
    }
}

bitmap.UnlockBits(bitmapData);

See Also

Reference