Loading Images

Why is it that if a BMP (24-bit) is loaded using SDL, the value of (image->pitch/image->format->BytesPerPixel) is not equal to image->w when the actual width of the image is an odd number? The image->pitch seems to always be forced to an even value. Does the BMP specification have to do anything with this? Any ideas?

Regards,
Nishal.

Why is it that if a BMP (24-bit) is loaded using SDL, the value of
(image->pitch/image->format->BytesPerPixel) is not equal to image->w when
the actual width of the image is an odd number? The image->pitch seems to
always be forced to an even value. Does the BMP specification have to do
anything with this? Any ideas?

Regards,
Nishal.

The specification is using 32 bit per pixel -> a line must be divisible by
4 bytes. On a bitmap wide of 639 the bitmaps wide in memory is 640 to be
divisible by 4 with 1 pixel/line garbage. That’s why you need to read the
data line by line with proper pitch, when you want to work with outside
SDL.
It’s the same when you loading jpg, tiff… with SDL_image.

Resize the bitmaps wide ( 639->640 for example) and the pitch will be
eqaul.On Sun, 23 Feb 2003 19:43:44 +0530, Nishal Thomas G. wrote:


Using M2, Opera’s revolutionary e-mail client: http://www.opera.com/m2/