home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / gutenprint / dither.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-03-15  |  6.1 KB  |  205 lines

  1. /*
  2.  * "$Id: dither.h,v 1.1 2004/09/17 18:38:01 rleigh Exp $"
  3.  *
  4.  *   libgimpprint dither header.
  5.  *
  6.  *   Copyright 1997-2000 Michael Sweet (mike@easysw.com) and
  7.  *    Robert Krawitz (rlk@alum.mit.edu)
  8.  *
  9.  *   This program is free software; you can redistribute it and/or modify it
  10.  *   under the terms of the GNU General Public License as published by the Free
  11.  *   Software Foundation; either version 2 of the License, or (at your option)
  12.  *   any later version.
  13.  *
  14.  *   This program is distributed in the hope that it will be useful, but
  15.  *   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  16.  *   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  17.  *   for more details.
  18.  *
  19.  *   You should have received a copy of the GNU General Public License
  20.  *   along with this program; if not, write to the Free Software
  21.  *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22.  *
  23.  * Revision History:
  24.  *
  25.  *   See ChangeLog
  26.  */
  27.  
  28. /**
  29.  * @file gutenprint/dither.h
  30.  * @brief Dither functions.
  31.  */
  32.  
  33. /*
  34.  * This file must include only standard C header files.  The core code must
  35.  * compile on generic platforms that don't support glib, gimp, gtk, etc.
  36.  */
  37.  
  38. #ifndef GUTENPRINT_DITHER_H
  39. #define GUTENPRINT_DITHER_H
  40.  
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44.  
  45. #ifdef HAVE_CONFIG_H
  46. #include <config.h>
  47. #endif
  48.  
  49. /*
  50.  * STP_ECOLOR_K must be 0
  51.  */
  52. #define STP_ECOLOR_K  0
  53. #define STP_ECOLOR_C  1
  54. #define STP_ECOLOR_M  2
  55. #define STP_ECOLOR_Y  3
  56. #define STP_NCOLORS (4)
  57.  
  58. typedef struct stp_dither_matrix_short
  59. {
  60.   int x;
  61.   int y;
  62.   int bytes;
  63.   int prescaled;
  64.   const unsigned short *data;
  65. } stp_dither_matrix_short_t;
  66.  
  67. typedef struct stp_dither_matrix_normal
  68. {
  69.   int x;
  70.   int y;
  71.   int bytes;
  72.   int prescaled;
  73.   const unsigned *data;
  74. } stp_dither_matrix_normal_t;
  75.  
  76. typedef struct stp_dither_matrix_generic
  77. {
  78.   int x;
  79.   int y;
  80.   int bytes;
  81.   int prescaled;
  82.   const void *data;
  83. } stp_dither_matrix_generic_t;
  84.  
  85. typedef struct dither_matrix_impl
  86. {
  87.   int base;
  88.   int exp;
  89.   int x_size;
  90.   int y_size;
  91.   int total_size;
  92.   int last_x;
  93.   int last_x_mod;
  94.   int last_y;
  95.   int last_y_mod;
  96.   int index;
  97.   int i_own;
  98.   int x_offset;
  99.   int y_offset;
  100.   unsigned fast_mask;
  101.   unsigned *matrix;
  102. } stp_dither_matrix_impl_t;
  103.  
  104. extern void stp_dither_matrix_iterated_init(stp_dither_matrix_impl_t *mat, size_t size,
  105.                         size_t exponent, const unsigned *array);
  106. extern void stp_dither_matrix_shear(stp_dither_matrix_impl_t *mat,
  107.                     int x_shear, int y_shear);
  108. extern void stp_dither_matrix_init(stp_dither_matrix_impl_t *mat, int x_size,
  109.                    int y_size, const unsigned int *array,
  110.                    int transpose, int prescaled);
  111. extern void stp_dither_matrix_init_short(stp_dither_matrix_impl_t *mat, int x_size,
  112.                      int y_size,
  113.                      const unsigned short *array,
  114.                      int transpose, int prescaled);
  115. extern int stp_dither_matrix_validate_array(const stp_array_t *array);
  116. extern void stp_dither_matrix_init_from_dither_array(stp_dither_matrix_impl_t *mat,
  117.                              const stp_array_t *array,
  118.                              int transpose);
  119. extern void stp_dither_matrix_destroy(stp_dither_matrix_impl_t *mat);
  120. extern void stp_dither_matrix_clone(const stp_dither_matrix_impl_t *src,
  121.                     stp_dither_matrix_impl_t *dest,
  122.                     int x_offset, int y_offset);
  123. extern void stp_dither_matrix_copy(const stp_dither_matrix_impl_t *src,
  124.                    stp_dither_matrix_impl_t *dest);
  125. extern void stp_dither_matrix_scale_exponentially(stp_dither_matrix_impl_t *mat,
  126.                           double exponent);
  127. extern void stp_dither_matrix_set_row(stp_dither_matrix_impl_t *mat, int y);
  128. extern stp_array_t *stp_find_standard_dither_array(int x_aspect, int y_aspect);
  129.  
  130.  
  131. typedef struct stp_dotsize
  132. {
  133.   unsigned bit_pattern;
  134.   double value;
  135. } stp_dotsize_t;
  136.  
  137. typedef struct stp_shade
  138. {
  139.   double value;
  140.   int numsizes;
  141.   const stp_dotsize_t *dot_sizes;
  142. } stp_shade_t;
  143.  
  144. extern stp_parameter_list_t stp_dither_list_parameters(const stp_vars_t *v);
  145.  
  146. extern void
  147. stp_dither_describe_parameter(const stp_vars_t *v, const char *name,
  148.                   stp_parameter_t *description);
  149.  
  150. extern void stp_dither_init(stp_vars_t *v, stp_image_t *image,
  151.                 int out_width, int xdpi, int ydpi);
  152. extern void stp_dither_set_iterated_matrix(stp_vars_t *v, size_t edge,
  153.                        size_t iterations,
  154.                        const unsigned *data,
  155.                        int prescaled,
  156.                        int x_shear, int y_shear);
  157. extern void stp_dither_set_matrix(stp_vars_t *v, const stp_dither_matrix_generic_t *mat,
  158.                   int transpose, int x_shear, int y_shear);
  159. extern void stp_dither_set_matrix_from_dither_array(stp_vars_t *v,
  160.                             const stp_array_t *array,
  161.                             int transpose);
  162. extern void stp_dither_set_transition(stp_vars_t *v, double);
  163. extern void stp_dither_set_randomizer(stp_vars_t *v, int color, double);
  164. extern void stp_dither_set_ink_spread(stp_vars_t *v, int spread);
  165. extern void stp_dither_set_adaptive_limit(stp_vars_t *v, double limit);
  166. extern int stp_dither_get_first_position(stp_vars_t *v, int color, int subchan);
  167. extern int stp_dither_get_last_position(stp_vars_t *v, int color, int subchan);
  168. extern void stp_dither_set_inks_simple(stp_vars_t *v, int color, int nlevels,
  169.                        const double *levels, double density,
  170.                        double darkness);
  171. extern void stp_dither_set_inks_full(stp_vars_t *v, int color, int nshades,
  172.                      const stp_shade_t *shades,
  173.                      double density, double darkness);
  174. extern void stp_dither_set_inks(stp_vars_t *v, int color,
  175.                 double density, double darkness,
  176.                 int nshades, const double *svalues,
  177.                 int ndotsizes, const double *dvalues);
  178.  
  179.  
  180. extern void stp_dither_add_channel(stp_vars_t *v, unsigned char *data,
  181.                    unsigned channel, unsigned subchannel);
  182.  
  183. extern unsigned char *stp_dither_get_channel(stp_vars_t *v,
  184.                          unsigned channel,
  185.                          unsigned subchannel);
  186.  
  187. extern void stp_dither(stp_vars_t *v, int row, int duplicate_line,
  188.                int zero_mask, const unsigned char *mask);
  189.  
  190. /* #ifdef STP_TESTDITHER */
  191. extern void stp_dither_internal(stp_vars_t *v, int row,
  192.                 const unsigned short *input,
  193.                 int duplicate_line, int zero_mask,
  194.                 const unsigned char *mask);
  195. /* #endif */
  196.  
  197. #ifdef __cplusplus
  198.   }
  199. #endif
  200.  
  201. #endif /* GUTENPRINT_DITHER_H */
  202. /*
  203.  * End of "$Id: dither.h,v 1.1 2004/09/17 18:38:01 rleigh Exp $".
  204.  */
  205.