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

include/gimp-print/curve.h

Go to the documentation of this file.
00001 /*
00002  * "$Id: curve.h,v 1.13 2004/05/30 01:26:15 rlk Exp $"
00003  *
00004  *   libgimpprint curve functions.
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 
00029 #ifndef GIMP_PRINT_CURVE_H
00030 #define GIMP_PRINT_CURVE_H
00031 
00032 #include <stdio.h>
00033 #include <stdlib.h>
00034 
00035 #include <gimp-print/sequence.h>
00036 
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040 
00041 
00042   /*
00043    * Curve code borrowed from GTK+, http://www.gtk.org/
00044    */
00045 
00061 struct stp_curve;
00063 typedef struct stp_curve stp_curve_t;
00064 
00066 typedef enum
00067 {
00069   STP_CURVE_TYPE_LINEAR,
00071   STP_CURVE_TYPE_SPLINE
00072 } stp_curve_type_t;
00073 
00075 typedef enum
00076 {
00078   STP_CURVE_WRAP_NONE,
00080   STP_CURVE_WRAP_AROUND
00081 } stp_curve_wrap_mode_t;
00082 
00084 typedef enum
00085 {
00087   STP_CURVE_COMPOSE_ADD,
00089   STP_CURVE_COMPOSE_MULTIPLY,
00091   STP_CURVE_COMPOSE_EXPONENTIATE
00092 } stp_curve_compose_t;
00093 
00095 typedef enum
00096 {
00098   STP_CURVE_BOUNDS_RESCALE,
00100   STP_CURVE_BOUNDS_CLIP,
00102   STP_CURVE_BOUNDS_ERROR
00103 } stp_curve_bounds_t;
00104 
00106 typedef struct
00107 {
00109   double x;
00111   double y;
00112 } stp_curve_point_t;
00113 
00126 extern stp_curve_t *stp_curve_create(stp_curve_wrap_mode_t wrap);
00127 
00136 extern stp_curve_t *stp_curve_create_copy(const stp_curve_t *curve);
00137 
00145 extern void stp_curve_copy(stp_curve_t *dest, const stp_curve_t *source);
00146 
00152 extern void stp_curve_destroy(stp_curve_t *curve);
00153 
00164 extern int stp_curve_set_bounds(stp_curve_t *curve, double low, double high);
00165 
00172 extern void stp_curve_get_bounds(const stp_curve_t *curve,
00173                                  double *low, double *high);
00174 
00180 extern stp_curve_wrap_mode_t stp_curve_get_wrap(const stp_curve_t *curve);
00181 
00187 extern int stp_curve_is_piecewise(const stp_curve_t *curve);
00188 
00189 /*
00190  * Get the range (lowest and highest value of points) in the curve.
00191  * This does not account for any interpolation that may place
00192  * intermediate points outside of the curve.
00193  * @param curve the curve to use.
00194  * @param low a pointer to double to store the lower limit in.
00195  * @param high a pointer to double to store the upper limit in.
00196  */
00197 extern void stp_curve_get_range(const stp_curve_t *curve,
00198                                 double *low, double *high);
00199 
00205 extern size_t stp_curve_count_points(const stp_curve_t *curve);
00206 
00213 extern int stp_curve_set_interpolation_type(stp_curve_t *curve,
00214                                             stp_curve_type_t itype);
00215 
00221 extern stp_curve_type_t stp_curve_get_interpolation_type(const stp_curve_t *curve);
00222 
00234 extern int stp_curve_set_data(stp_curve_t *curve, size_t count,
00235                               const double *data);
00236 
00250 extern int stp_curve_set_data_points(stp_curve_t *curve, size_t count,
00251                                      const stp_curve_point_t *data);
00252 
00264 extern int stp_curve_set_float_data(stp_curve_t *curve,
00265                                     size_t count, const float *data);
00266 
00278 extern int stp_curve_set_long_data(stp_curve_t *curve,
00279                                    size_t count, const long *data);
00280 
00293 extern int stp_curve_set_ulong_data(stp_curve_t *curve,
00294                                     size_t count, const unsigned long *data);
00295 
00307 extern int stp_curve_set_int_data(stp_curve_t *curve,
00308                                   size_t count, const int *data);
00309 
00322 extern int stp_curve_set_uint_data(stp_curve_t *curve,
00323                                    size_t count, const unsigned int *data);
00324 
00336 extern int stp_curve_set_short_data(stp_curve_t *curve,
00337                                     size_t count, const short *data);
00338 
00351 extern int stp_curve_set_ushort_data(stp_curve_t *curve,
00352                                      size_t count, const unsigned short *data);
00353 
00366 extern stp_curve_t *stp_curve_get_subrange(const stp_curve_t *curve,
00367                                            size_t start, size_t count);
00368 
00369 /*
00370  * Set part of a curve to the range in another curve.  The data in the
00371  * range must fit within both the bounds and the number of points in
00372  * the first curve.  The curve must be a dense (equally-spaced) curve.
00373  * @param curve the curve to use (destination).
00374  * @param range the source curve.
00375  * @param start the starting point in the destination range.
00376  * @param returns 1 on success, 0 on failure.
00377  */
00378 extern int stp_curve_set_subrange(stp_curve_t *curve, const stp_curve_t *range,
00379                                   size_t start);
00380 
00391 extern const double *stp_curve_get_data(const stp_curve_t *curve, size_t *count);
00392 
00403 extern const stp_curve_point_t *stp_curve_get_data_points(const stp_curve_t *curve, size_t *count);
00404 
00405 
00415 extern const float *stp_curve_get_float_data(const stp_curve_t *curve,
00416                                              size_t *count);
00417 
00427 extern const long *stp_curve_get_long_data(const stp_curve_t *curve,
00428                                            size_t *count);
00429 
00439 extern const unsigned long *stp_curve_get_ulong_data(const stp_curve_t *curve,
00440                                                      size_t *count);
00441 
00451 extern const int *stp_curve_get_int_data(const stp_curve_t *curve,
00452                                          size_t *count);
00453 
00463 extern const unsigned int *stp_curve_get_uint_data(const stp_curve_t *curve,
00464                                                    size_t *count);
00465 
00475 extern const short *stp_curve_get_short_data(const stp_curve_t *curve,
00476                                              size_t *count);
00477 
00487 extern const unsigned short *stp_curve_get_ushort_data(const stp_curve_t *curve,
00488                                                        size_t *count);
00489 
00498 extern const stp_sequence_t *stp_curve_get_sequence(const stp_curve_t *curve);
00499 
00514 extern int stp_curve_set_gamma(stp_curve_t *curve, double f_gamma);
00515 
00521 extern double stp_curve_get_gamma(const stp_curve_t *curve);
00522 
00533 extern int stp_curve_set_point(stp_curve_t *curve, size_t where, double data);
00534 
00543 extern int stp_curve_get_point(const stp_curve_t *curve, size_t where,
00544                                double *data);
00545 
00558 extern int stp_curve_interpolate_value(const stp_curve_t *curve,
00559                                        double where, double *result);
00560 
00573 extern int stp_curve_resample(stp_curve_t *curve, size_t points);
00574 
00585 extern int stp_curve_rescale(stp_curve_t *curve, double scale,
00586                              stp_curve_compose_t mode,
00587                              stp_curve_bounds_t bounds_mode);
00588 
00604 extern int stp_curve_write(FILE *file, const stp_curve_t *curve);
00605 
00621 extern char *stp_curve_write_string(const stp_curve_t *curve);
00622 
00631 extern stp_curve_t *stp_curve_create_from_stream(FILE* fp);
00632 
00641 extern stp_curve_t *stp_curve_create_from_file(const char* file);
00642 
00651 extern stp_curve_t *stp_curve_create_from_string(const char* string);
00652 
00673 extern int stp_curve_compose(stp_curve_t **retval,
00674                              stp_curve_t *a, stp_curve_t *b,
00675                              stp_curve_compose_t mode, int points);
00676 
00679 #ifdef __cplusplus
00680   }
00681 #endif
00682 
00683 #endif /* GIMP_PRINT_CURVE_H */
00684 /*
00685  * End of "$Id: curve.h,v 1.13 2004/05/30 01:26:15 rlk Exp $".
00686  */

Generated on Wed Aug 25 07:56:13 2004 for libgimpprint API Reference by doxygen 1.3.6