Panda3D

pnmbitio.h
1 /*\
2 * bitio.h - bitstream I/O
3 *
4 * Works for (sizeof(unsigned long)-1)*8 bits.
5 *
6 * Copyright (C) 1992 by David W. Sanderson.
7 *
8 * Permission to use, copy, modify, and distribute this software and its
9 * documentation for any purpose and without fee is hereby granted,
10 * provided that the above copyright notice appear in all copies and
11 * that both that copyright notice and this permission notice appear
12 * in supporting documentation. This software is provided "as is"
13 * without express or implied warranty.
14 \*/
15
16 #ifndef _BITIO_H_
17 #define _BITIO_H_
18
19 #include "pandabase.h"
20 #include "pnmimage_base.h"
21
22 typedef struct bitstream *BITSTREAM;
23
24 /*
25 * pm_bitinit() - allocate and return a BITSTREAM for the given FILE*.
26 *
27 * mode must be one of "r" or "w", according to whether you will be
28 * reading from or writing to the BITSTREAM.
29 *
30 * Returns 0 on error.
31 */
32
33 extern EXPCL_PANDA_PNMIMAGE BITSTREAM pm_bitinit(std::istream *f, const char *mode);
34 extern EXPCL_PANDA_PNMIMAGE BITSTREAM pm_bitinit(std::ostream *f, const char *mode);
35
36 /*
37 * pm_bitfini() - deallocate the given BITSTREAM.
38 *
39 * You must call this after you are done with the BITSTREAM.
40 *
41 * It may flush some bits left in the buffer.
42 *
43 * Returns the number of bytes written, -1 on error.
44 */
45
46 extern EXPCL_PANDA_PNMIMAGE int pm_bitfini(BITSTREAM b);
47
48 /*
49 * pm_bitread() - read the next nbits into *val from the given file.
50 *
51 * Returns the number of bytes read, -1 on error.
52 */
53
54 extern EXPCL_PANDA_PNMIMAGE int pm_bitread(BITSTREAM b, unsigned long nbits, unsigned long *val);
55
56 /*
57 * pm_bitwrite() - write the low nbits of val to the given file.
58 *
59 * The last pm_bitwrite() must be followed by a call to pm_bitflush().
60 *
61 * Returns the number of bytes written, -1 on error.
62 */
63
64 extern EXPCL_PANDA_PNMIMAGE int pm_bitwrite(BITSTREAM b, unsigned long nbits, unsigned long val);
65
66 #endif /* _BITIO_H_ */
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pnmimage_base.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.