Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals  

include/gimp-print/curve.h

Go to the documentation of this file.
00001 /*
00002  * "$Id: curve.h,v 1.11 2004/05/09 16:06:05 rleigh 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 
00105 
00117 extern stp_curve_t *stp_curve_create(stp_curve_wrap_mode_t wrap);
00118 
00127 extern stp_curve_t *stp_curve_create_copy(const stp_curve_t *curve);
00128 
00136 extern void stp_curve_copy(stp_curve_t *dest, const stp_curve_t *source);
00137 
00143 extern void stp_curve_destroy(stp_curve_t *curve);
00144 
00155 extern int stp_curve_set_bounds(stp_curve_t *curve, double low, double high);
00156 
00163 extern void stp_curve_get_bounds(const stp_curve_t *curve,
00164                                  double *low, double *high);
00165 
00171 extern stp_curve_wrap_mode_t stp_curve_get_wrap(const stp_curve_t *curve);
00172 
00173 /*
00174  * Get the range (lowest and highest value of points) in the curve.
00175  * This does not account for any interpolation that may place
00176  * intermediate points outside of the curve.
00177  * @param curve the curve to use.
00178  * @param low a pointer to double to store the lower limit in.
00179  * @param high a pointer to double to store the upper limit in.
00180  */
00181 extern void stp_curve_get_range(const stp_curve_t *curve,
00182                                 double *low, double *high);
00183 
00189 extern size_t stp_curve_count_points(const stp_curve_t *curve);
00190 
00197 extern int stp_curve_set_interpolation_type(stp_curve_t *curve,
00198                                             stp_curve_type_t itype);
00199 
00205 extern stp_curve_type_t stp_curve_get_interpolation_type(const stp_curve_t *curve);
00206 
00218 extern int stp_curve_set_data(stp_curve_t *curve, size_t count,
00219                               const double *data);
00220 
00232 extern int stp_curve_set_float_data(stp_curve_t *curve,
00233                                     size_t count, const float *data);
00234 
00246 extern int stp_curve_set_long_data(stp_curve_t *curve,
00247                                    size_t count, const long *data);
00248 
00260 extern int stp_curve_set_ulong_data(stp_curve_t *curve,
00261                                     size_t count, const unsigned long *data);
00262 
00274 extern int stp_curve_set_int_data(stp_curve_t *curve,
00275                                   size_t count, const int *data);
00276 
00288 extern int stp_curve_set_uint_data(stp_curve_t *curve,
00289                                    size_t count, const unsigned int *data);
00290 
00302 extern int stp_curve_set_short_data(stp_curve_t *curve,
00303                                     size_t count, const short *data);
00304 
00316 extern int stp_curve_set_ushort_data(stp_curve_t *curve,
00317                                      size_t count, const unsigned short *data);
00318 
00330 extern stp_curve_t *stp_curve_get_subrange(const stp_curve_t *curve,
00331                                            size_t start, size_t count);
00332 
00333 /*
00334  * Set part of a curve to the range in another curve.  The data in the
00335  * range must fit within both the bounds and the number of points in
00336  * the first curve.
00337  * @param curve the curve to use (destination).
00338  * @param range the source curve.
00339  * @param start the starting point in the destination range.
00340  * @param returns 1 on success, 0 on failure.
00341  */
00342 extern int stp_curve_set_subrange(stp_curve_t *curve, const stp_curve_t *range,
00343                                   size_t start);
00344 
00354 extern const double *stp_curve_get_data(const stp_curve_t *curve, size_t *count);
00355 
00356 
00366 extern const float *stp_curve_get_float_data(const stp_curve_t *curve,
00367                                              size_t *count);
00368 
00378 extern const long *stp_curve_get_long_data(const stp_curve_t *curve,
00379                                            size_t *count);
00380 
00390 extern const unsigned long *stp_curve_get_ulong_data(const stp_curve_t *curve,
00391                                                      size_t *count);
00392 
00402 extern const int *stp_curve_get_int_data(const stp_curve_t *curve,
00403                                          size_t *count);
00404 
00414 extern const unsigned int *stp_curve_get_uint_data(const stp_curve_t *curve,
00415                                                    size_t *count);
00416 
00426 extern const short *stp_curve_get_short_data(const stp_curve_t *curve,
00427                                              size_t *count);
00428 
00438 extern const unsigned short *stp_curve_get_ushort_data(const stp_curve_t *curve,
00439                                                        size_t *count);
00440 
00448 extern const stp_sequence_t *stp_curve_get_sequence(const stp_curve_t *curve);
00449 
00463 extern int stp_curve_set_gamma(stp_curve_t *curve, double f_gamma);
00464 
00470 extern double stp_curve_get_gamma(const stp_curve_t *curve);
00471 
00481 extern int stp_curve_set_point(stp_curve_t *curve, size_t where, double data);
00482 
00491 extern int stp_curve_get_point(const stp_curve_t *curve, size_t where,
00492                                double *data);
00493 
00505 extern int stp_curve_interpolate_value(const stp_curve_t *curve,
00506                                        double where, double *result);
00507 
00518 extern int stp_curve_resample(stp_curve_t *curve, size_t points);
00519 
00530 extern int stp_curve_rescale(stp_curve_t *curve, double scale,
00531                              stp_curve_compose_t mode,
00532                              stp_curve_bounds_t bounds_mode);
00533 
00549 extern int stp_curve_write(FILE *file, const stp_curve_t *curve);
00550 
00566 extern char *stp_curve_write_string(const stp_curve_t *curve);
00567 
00576 extern stp_curve_t *stp_curve_create_from_stream(FILE* fp);
00577 
00586 extern stp_curve_t *stp_curve_create_from_file(const char* file);
00587 
00596 extern stp_curve_t *stp_curve_create_from_string(const char* string);
00597 
00618 extern int stp_curve_compose(stp_curve_t **retval,
00619                              stp_curve_t *a, stp_curve_t *b,
00620                              stp_curve_compose_t mode, int points);
00621 
00624 #ifdef __cplusplus
00625   }
00626 #endif
00627 
00628 #endif /* GIMP_PRINT_CURVE_H */
00629 /*
00630  * End of "$Id: curve.h,v 1.11 2004/05/09 16:06:05 rleigh Exp $".
00631  */

Generated on Wed May 12 20:21:27 2004 for libgimpprint API Reference by doxygen1.2.17