CreatePixmap align_bytes parameter?

BlitzMax Forums/BlitzMax Beginners Area/CreatePixmap align_bytes parameter?

jondecker76(Posted 2010) [#1]
What is this parameter for exactly? I can find no documentation on it and nothing came up on a search of the forums.


AdamRedwoods(Posted 2010) [#2]
Did you ever get this answered? The answer is discussed here:
http://www.blitzbasic.com/Community/posts.php?topic=60671


Pitch is the total number of bytes, rounded up to the nearest multiple of 4 (or whatever the alignment is), that is needed to contain a single row of pixels.

When you create the pixmap, if the `alignment` is 4, that means you want the start of each row to begin on a 4-byte aligned memory address. The amount of bytes per row needed to achieve this is the Pitch, which may be more than the total number of bytes taken up by actual pixel data.




ImaginaryHuman(Posted 2010) [#3]
And part of the reason for having this alignment is that typically you will be accessing one whole pixel at a time, which will likely be in RGB or RGBA format, and that means you may want to ensure your pixmap has `whole pixels` in it. Also reading/writing to properly integer-aligned boundaries is faster for the CPU usually.