home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / graphics / randjpeg_1 / source / h / internal next >
Text File  |  1996-01-21  |  3KB  |  114 lines

  1. /* internal.h
  2.  * AUTHOR:      Cy Booker, cy@cheepnis.demon.co.uk
  3.  * LICENSE:     FreeWare, Copyright (c) 1996 Cy Booker
  4.  * PURPOSE:     common code
  5.  */
  6.  
  7. #ifndef internal_h
  8. #define internal_h
  9.  
  10.  
  11. #include "main.h"
  12.  
  13.  
  14. #include "OS:hourglass.h"
  15. #include "OS:macros.h"
  16. #include "OS:types.h"
  17.  
  18.  
  19.  
  20. /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  21.  */
  22.  
  23. typedef struct process_image    process_image;
  24.  
  25. typedef struct rgbtuple         rgbtuple;
  26.  
  27. typedef bits (*rgbtuple_fn)(rgbtuple *, int r, int g, int b);
  28.  
  29. struct process_image {
  30.   byte                  *buffer;        /* i/o (must be word-aligned) */
  31.   int                   pixel_width;    /* > 0 */
  32.   int                   pixel_height;   /* > 0 */
  33.   int                   source_line_length;     /* must be multiple of 4 */
  34.   int                   dest_line_length;
  35.   rgbtuple_fn           fn;
  36. };
  37.  
  38. struct rgbtuple {
  39.         int     red;
  40.         int     grn;
  41.         int     blu;
  42. };
  43.  
  44.  
  45.  
  46. extern rgbtuple default_wimp_palette_as_tuples[256];
  47.  
  48.  
  49. /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  50.  * defined in s.map
  51.  */
  52.  
  53. extern bits map_scaled_rgb_to_8bpp_colour_number_quick(
  54.                 rgbtuple        *out,
  55.                 int             red,
  56.                 int             green,
  57.                 int             blue);
  58.  
  59.  
  60.  
  61. /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  62.  * defined in s.mapchangefsi
  63.  */
  64.  
  65. extern bits map_scaled_rgb_to_8bpp_colour_number_changefsi(
  66.                 rgbtuple        *out,
  67.                 int             red,
  68.                 int             green,
  69.                 int             blue);
  70.  
  71.  
  72.  
  73. /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  74.  */
  75.  
  76. extern void process_image_8bpp_burkes(const process_image *p);
  77.  
  78. extern void process_image_8bpp_dither2x2(const process_image *p);
  79.                 
  80. extern void process_image_8bpp_floyd_steinberg(const process_image *p);
  81.  
  82. extern void process_image_8bpp_nearest(const process_image *p);
  83.  
  84. extern void process_image_8bpp_jarvis_judice_ninke(const process_image *p);
  85.  
  86. extern void process_image_8bpp_nearest(const process_image *p);
  87.  
  88. extern void process_image_8bpp_stucki(const process_image *p);
  89.  
  90. extern void process_image_8bpp_sierra3(const process_image *p);
  91.  
  92. extern void process_image_8bpp_sierra2(const process_image *p);
  93.  
  94. extern void process_image_8bpp_sierra2_4a(const process_image *p);
  95.  
  96.  
  97. #define INPUT \
  98.       colour = source[x];                        /* source pixel &ttbbggrr */\
  99.       red = (colour >> (0*8)) & 0xff; red |= red << 8;  /* scale to internal representation */\
  100.       grn = (colour >> (1*8)) & 0xff; grn |= grn << 8;\
  101.       blu = (colour >> (2*8)) & 0xff; blu |= blu << 8
  102.  
  103.  
  104.  
  105. #define PROCESS \
  106.       dest[x] = (*fn)(&error, red, grn, blu);   /* write pixel */\
  107.       red = error.red;                          /* error */\
  108.       grn = error.grn;\
  109.       blu = error.blu
  110.  
  111.  
  112.  
  113. #endif /* internal_h */
  114.