[SDL] Doubts about screen Pitch and things related to it.
mystml at adinet.com.uy
Mon Jun 19 07:38:37 PDT 2006
El lun, 19-06-2006 a las 10:47 -0300, Alfred Reinold Baudisch
I don't understand PITCH.
You have a 2D dataset (the screen or window) which you want to represent
as a linear dataset (an array, given by a pointer).
The easiest way to arrange the screen into a linear array is to take all
the pixels of the first row, then all the pixels of the second row, and
so on. For a 6x3 screen like this one
you get an array like this
Row 0 starts at index 0, row 1 starts at index 6 (1*6), row 2 starts at
index 12 (2*6). 6 is the WIDTH of the surface.
However, assume that for some obscure, hardware-related issue, it's
better for the video card to have rows start at indexes which are
multiples of 8 instead of 6. So you take your 6x3 screen and waste some
bytes at the end of each row to make each row 8 spaces wide, like this :
When you put that in a linear array, you now get
Row 0 starts at index 0, row 1 starts at index 8 (1*8), row 2 starts at
index 16 (2*8) and the video card is happy. The WIDTH of the surface is
still 6, but the PITCH is 8 - the "distance" between consecutive rows,
which as you see not always matches the width of a row.
Hope this helps!
Mystery Studio - http://www.mysterystudio.com
Gabriel on Graphics - http://gabrielongraphics.blogspot.com
More information about the SDL