Castle Game Engine |
packed record TBitmapChar
UnitDeclaration
Description
Sample character may look like this : CharX = record Info: TBitmapCharInfo Data: packed array[0..23]of byte; end = ( Info : ( Alignment : 2; XOrig : 0; YOrig : 0; XMove : 10; YMove : 0; Width : 8; Height : 12 ); Data : ($AA, $00, $BB, $00, .... ); );
Notes about example above: The row has Width = 8 which means that we need only 8 bits (one byte) to store it. But since Alignment = 2, we need to use some multiply of 2 bytes to store a row, which means that each row actually uses 2 bytes (even though the contents of 2nd byte are always meaningless). E.g. if you will pass this data to OpenGL, you should appropriately use Sure, this is rather extreme example, since in this case we're wasting half memory just to get Alignment = 2. Well, this is only an example. Also, Alignment may sometimes give us better speed. E.g. for OpenGL's glBitmap (even though if you will use OpenGL's display list, it will not actually matter that much, since then OpenGL will probably internally convert to the best alignment anyway). Summing the example, we have 2 bytes and 12 rows (Height = 2) so we need 24 bytes to store this character. The precise formula to calculate how many bytes are used to store a character is
Rows are specified in Data from lower to upper (just like OpenGL's Note that this is packed record so I'm sure that SizeOf(record Info: TBitmapCharInfo; Data: packed array[0..n]of byte; ) = SizeOf(TBitmapCharInfo) + (n+1) * SizeOf(Byte)
I.e. there's no padding between Info and Data. OverviewFields
DescriptionFields
Generated by PasDoc 0.12.1 on 2013-02-04 20:26:49 |