Help with blockread/blockwrite
Frank Heckenbach
ih8mj at fjf.gnu.de
Wed Feb 18 18:02:30 CET 2004
Prof A Olowofoyeku (The African Chief) wrote:
> On 7 Feb 2004 at 21:25, Peter Norton wrote:
>
> > The Chief wrote:
> > > Please send an example of such code.
> >
> > <code snippet>
> > bmpinfo = record (*BMP header*)
> [...]
> You will need to pack the record (bearing in mind CBF's warning about
> portability, etc.). Using "packed" may not always be portable. The
> following solution may or may not be portable (Frank can tell us):
>
> type
> {$ifdef __GPC__}{$pack-struct, maximum-field-alignment 8} {$endif}
> bmpinfo = record (*BMP header*)
> b1, b2 : char;
> size : integer;
> reserved : integer;
> offset : integer;
> headersize : integer;
> width : integer;
> height : integer;
> planes : shortword;
> bpp : shortword;
> compression : integer;
> comprsize : integer;
> horresolution : integer;
> verresolution : integer;
> usedcolors : integer;
> importantcol : integer;
> end;
> {$ifdef __GPC__}{$no-pack-struct, maximum-field-alignment 0}{$endif}
To be portable, you cannot use types like `Integer' and `ShortWord'
which can have different sizes. You can define your own types to be
`Integer attribute (Size = 32)', `Cardinal attribute (Size = 16)'
etc. Also you have to do explicit endianness conversions (see
`ConvertFromLittleEndian' etc. in gpc.pas).
Frank
--
Frank Heckenbach, frank at g-n-u.de, http://fjf.gnu.de/, 7977168E
GPC To-Do list, latest features, fixed bugs:
http://www.gnu-pascal.de/todo.html
GPC download signing key: 51FF C1F0 1A77 C6C2 4482 4DDC 117A 9773 7F88 1707
More information about the Gpc
mailing list