00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
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
00191
00192
00193
00194
00195
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
00371
00372
00373
00374
00375
00376
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
00684
00685
00686