uBytes

The number of bytes in the row to retrieve. To get a full row, use the value in the BitmapBytesPerLine Property.

When getting less than full row, you must consider the bits per pixel. For a 1-bit bitmap, each byte represents 8 pixels. For a 4-bit bitmap, each byte represents 2 pixels. For an 8-bit bitmap, each byte represents 1 pixel. For a 16-bit bitmap, every 2 bytes represent one pixel. For 24-bit images, every three bytes represent one pixel. For a 32-bit bitmap, every four bytes represent one pixel. For 48-bit images, every six bytes represent one pixel. For 64-bit images, every eight bytes represent one pixel.

You can use the bitmap handle's BitmapBits Property with integer math to calculate the number of bytes needed for a particular number of pixels.

For example (In C++ Builder Syntax):

NumberOfBytes = (Bitmap.BitmapBits * NumberOfPixels) / 8;
if ((Bitmap.BitmapBits * NumberOfPixels) % 8)
      ++NumberOfBytes; /* Round up if necessary for a 1- or 4-bit image */