Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

dither.h

Go to the documentation of this file.
00001 /*
00002  * "$Id: dither.h,v 1.1 2004/09/17 18:38:01 rleigh Exp $"
00003  *
00004  *   libgimpprint dither header.
00005  *
00006  *   Copyright 1997-2000 Michael Sweet (mike@easysw.com) and
00007  *      Robert Krawitz (rlk@alum.mit.edu)
00008  *
00009  *   This program is free software; you can redistribute it and/or modify it
00010  *   under the terms of the GNU General Public License as published by the Free
00011  *   Software Foundation; either version 2 of the License, or (at your option)
00012  *   any later version.
00013  *
00014  *   This program is distributed in the hope that it will be useful, but
00015  *   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00016  *   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00017  *   for more details.
00018  *
00019  *   You should have received a copy of the GNU General Public License
00020  *   along with this program; if not, write to the Free Software
00021  *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00022  *
00023  * Revision History:
00024  *
00025  *   See ChangeLog
00026  */
00027 
00033 /*
00034  * This file must include only standard C header files.  The core code must
00035  * compile on generic platforms that don't support glib, gimp, gtk, etc.
00036  */
00037 
00038 #ifndef GUTENPRINT_DITHER_H
00039 #define GUTENPRINT_DITHER_H
00040 
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044 
00045 #ifdef HAVE_CONFIG_H
00046 #include <config.h>
00047 #endif
00048 
00049 /*
00050  * STP_ECOLOR_K must be 0
00051  */
00052 #define STP_ECOLOR_K  0
00053 #define STP_ECOLOR_C  1
00054 #define STP_ECOLOR_M  2
00055 #define STP_ECOLOR_Y  3
00056 #define STP_NCOLORS (4)
00057 
00058 typedef struct stp_dither_matrix_short
00059 {
00060   int x;
00061   int y;
00062   int bytes;
00063   int prescaled;
00064   const unsigned short *data;
00065 } stp_dither_matrix_short_t;
00066 
00067 typedef struct stp_dither_matrix_normal
00068 {
00069   int x;
00070   int y;
00071   int bytes;
00072   int prescaled;
00073   const unsigned *data;
00074 } stp_dither_matrix_normal_t;
00075 
00076 typedef struct stp_dither_matrix_generic
00077 {
00078   int x;
00079   int y;
00080   int bytes;
00081   int prescaled;
00082   const void *data;
00083 } stp_dither_matrix_generic_t;
00084 
00085 typedef struct dither_matrix_impl
00086 {
00087   int base;
00088   int exp;
00089   int x_size;
00090   int y_size;
00091   int total_size;
00092   int last_x;
00093   int last_x_mod;
00094   int last_y;
00095   int last_y_mod;
00096   int index;
00097   int i_own;
00098   int x_offset;
00099   int y_offset;
00100   unsigned fast_mask;
00101   unsigned *matrix;
00102 } stp_dither_matrix_impl_t;
00103 
00104 extern void stp_dither_matrix_iterated_init(stp_dither_matrix_impl_t *mat, size_t size,
00105                                             size_t exponent, const unsigned *array);
00106 extern void stp_dither_matrix_shear(stp_dither_matrix_impl_t *mat,
00107                                     int x_shear, int y_shear);
00108 extern void stp_dither_matrix_init(stp_dither_matrix_impl_t *mat, int x_size,
00109                                    int y_size, const unsigned int *array,
00110                                    int transpose, int prescaled);
00111 extern void stp_dither_matrix_init_short(stp_dither_matrix_impl_t *mat, int x_size,
00112                                          int y_size,
00113                                          const unsigned short *array,
00114                                          int transpose, int prescaled);
00115 extern int stp_dither_matrix_validate_array(const stp_array_t *array);
00116 extern void stp_dither_matrix_init_from_dither_array(stp_dither_matrix_impl_t *mat,
00117                                                      const stp_array_t *array,
00118                                                      int transpose);
00119 extern void stp_dither_matrix_destroy(stp_dither_matrix_impl_t *mat);
00120 extern void stp_dither_matrix_clone(const stp_dither_matrix_impl_t *src,
00121                                     stp_dither_matrix_impl_t *dest,
00122                                     int x_offset, int y_offset);
00123 extern void stp_dither_matrix_copy(const stp_dither_matrix_impl_t *src,
00124                                    stp_dither_matrix_impl_t *dest);
00125 extern void stp_dither_matrix_scale_exponentially(stp_dither_matrix_impl_t *mat,
00126                                                   double exponent);
00127 extern void stp_dither_matrix_set_row(stp_dither_matrix_impl_t *mat, int y);
00128 extern stp_array_t *stp_find_standard_dither_array(int x_aspect, int y_aspect);
00129 
00130 
00131 typedef struct stp_dotsize
00132 {
00133   unsigned bit_pattern;
00134   double value;
00135 } stp_dotsize_t;
00136 
00137 typedef struct stp_shade
00138 {
00139   double value;
00140   int numsizes;
00141   const stp_dotsize_t *dot_sizes;
00142 } stp_shade_t;
00143 
00144 extern stp_parameter_list_t stp_dither_list_parameters(const stp_vars_t *v);
00145 
00146 extern void
00147 stp_dither_describe_parameter(const stp_vars_t *v, const char *name,
00148                               stp_parameter_t *description);
00149 
00150 extern void stp_dither_init(stp_vars_t *v, stp_image_t *image,
00151                             int out_width, int xdpi, int ydpi);
00152 extern void stp_dither_set_iterated_matrix(stp_vars_t *v, size_t edge,
00153                                            size_t iterations,
00154                                            const unsigned *data,
00155                                            int prescaled,
00156                                            int x_shear, int y_shear);
00157 extern void stp_dither_set_matrix(stp_vars_t *v, const stp_dither_matrix_generic_t *mat,
00158                                   int transpose, int x_shear, int y_shear);
00159 extern void stp_dither_set_matrix_from_dither_array(stp_vars_t *v,
00160                                                     const stp_array_t *array,
00161                                                     int transpose);
00162 extern void stp_dither_set_transition(stp_vars_t *v, double);
00163 extern void stp_dither_set_randomizer(stp_vars_t *v, int color, double);
00164 extern void stp_dither_set_ink_spread(stp_vars_t *v, int spread);
00165 extern void stp_dither_set_adaptive_limit(stp_vars_t *v, double limit);
00166 extern int stp_dither_get_first_position(stp_vars_t *v, int color, int subchan);
00167 extern int stp_dither_get_last_position(stp_vars_t *v, int color, int subchan);
00168 extern void stp_dither_set_inks_simple(stp_vars_t *v, int color, int nlevels,
00169                                        const double *levels, double density,
00170                                        double darkness);
00171 extern void stp_dither_set_inks_full(stp_vars_t *v, int color, int nshades,
00172                                      const stp_shade_t *shades,
00173                                      double density, double darkness);
00174 extern void stp_dither_set_inks(stp_vars_t *v, int color,
00175                                 double density, double darkness,
00176                                 int nshades, const double *svalues,
00177                                 int ndotsizes, const double *dvalues);
00178 
00179 
00180 extern void stp_dither_add_channel(stp_vars_t *v, unsigned char *data,
00181                                    unsigned channel, unsigned subchannel);
00182 
00183 extern unsigned char *stp_dither_get_channel(stp_vars_t *v,
00184                                              unsigned channel,
00185                                              unsigned subchannel);
00186 
00187 extern void stp_dither(stp_vars_t *v, int row, int duplicate_line,
00188                        int zero_mask, const unsigned char *mask);
00189 
00190 /* #ifdef STP_TESTDITHER */
00191 extern void stp_dither_internal(stp_vars_t *v, int row,
00192                                 const unsigned short *input,
00193                                 int duplicate_line, int zero_mask,
00194                                 const unsigned char *mask);
00195 /* #endif */
00196 
00197 #ifdef __cplusplus
00198   }
00199 #endif
00200 
00201 #endif /* GUTENPRINT_DITHER_H */
00202 /*
00203  * End of "$Id: dither.h,v 1.1 2004/09/17 18:38:01 rleigh Exp $".
00204  */

Generated on Thu Feb 10 19:29:29 2005 for libgutenprint API Reference by  doxygen 1.4.1