i_rle.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* This file is part of the GNU plotutils package. Copyright (C) 1995,
  2. 1996, 1997, 1998, 1999, 2000, 2005, 2008, Free Software Foundation, Inc.
  3. The GNU plotutils package is free software. You may redistribute it
  4. and/or modify it under the terms of the GNU General Public License as
  5. published by the Free Software foundation; either version 2, or (at your
  6. option) any later version.
  7. The GNU plotutils package is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. General Public License for more details.
  11. You should have received a copy of the GNU General Public License along
  12. with the GNU plotutils package; see the file COPYING. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
  14. Boston, MA 02110-1301, USA. */
  15. /* This header file (i_rle.h) defines the external interface to the module
  16. i_rle.c, which does run-length encoding on a sequence of integers
  17. ("pixel values"), and writes the resulting encoded sequence to an output
  18. stream. The encoded sequence should be GIF-compatible, even though the
  19. compression technique is not LZW.
  20. The module encapsulates the miGIF compression routines, originally
  21. written by der Mouse and ivo. Their copyright notice appears in
  22. i_rle.c. */
  23. /* an `int' should be able to hold 2**GIFBITS distinct values, together
  24. with -1 */
  25. #define GIFBITS 12
  26. /* the RLE output structure */
  27. typedef struct
  28. {
  29. int rl_pixel;
  30. int rl_basecode;
  31. int rl_count;
  32. int rl_table_pixel;
  33. int rl_table_max;
  34. bool just_cleared;
  35. int out_bits;
  36. int out_bits_init;
  37. int out_count;
  38. int out_bump;
  39. int out_bump_init;
  40. int out_clear;
  41. int out_clear_init;
  42. int max_ocodes;
  43. int code_clear;
  44. int code_eof;
  45. unsigned int obuf;
  46. int obits;
  47. FILE *ofile;
  48. #ifdef LIBPLOTTER
  49. ostream *outstream;
  50. #endif
  51. unsigned char oblock[256];
  52. int oblen;
  53. } rle_out;
  54. /* create, initialize, and return a new RLE output structure */
  55. #ifdef LIBPLOTTER
  56. extern rle_out *_rle_init (FILE *fp, ostream *out, int bit_depth);
  57. #else
  58. extern rle_out *_rle_init (FILE *fp, int bit_depth);
  59. #endif
  60. /* write a single integer (pixel) to the structure */
  61. extern void _rle_do_pixel (rle_out *rle, int c);
  62. /* wind things up and deallocate the RLE output structure */
  63. extern void _rle_terminate (rle_out *rle);