hi, I was checking the value of the pitch for various bitmaps loaded into an sdl_surface, and if my understanding of what pitch is is correct (surface scanline in bytes), then for some images I’ve gotten odd results. For a bitmap with a width of 107 pixels (bit-depth 8) the pitch was returned as 108, and for a bitmap with a width of 50 pixels(still 8bit) the pitch was returned as 52. So is that normal behavior or are my images likely corrupted, or what?
Yes, that is normal. Pitch is not byte count of one line of pixels.
Pitch (aka stride) is number of bytes from beginning of one line to
next. So it must be at least width * bytes_per_pixel. Of course, it
can be greater (but never smaller). Usually it is rounded to next
number that is divisible by 4.
Here is some explaining from Direct3D9 surfaces (same idea):
http://msdn.microsoft.com/en-us/library/windows/desktop/bb206357.aspx
If you want to get size of one line of pixels size in bytes, then
multiply width by bytes_per_pixel yourself.–
M?rti?? Mo?eiko
On Mon, Jan 2, 2012 at 6:47 PM, Omar Eshmawi <neo_storm at live.com> wrote:
hi, I was checking the value of the pitch for various bitmaps loaded into an
sdl_surface, and if my understanding of what pitch is is correct (surface
scanline in bytes), then for some images I’ve gotten odd results. For a
bitmap?with a width of 107 pixels (bit-depth 8) the pitch was returned as
108, and for a bitmap with a width of 50 pixels(still 8bit) the pitch was
returned as 52. So is that normal behavior or are my images likely
corrupted, or what?
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
oh it ROUNDS it, that explains why width*bytesperpixel didn’t work, Thanks! so is that an sdl specific thing?
also-- ignore my complaining about my images, I found out they were fine but I had them in a different folder named with unicode characters so that presented a problem to some image editing programs.