1 #ifndef PROTO_H_
2 #define PROTO_H_
3 #include <stdint.h>
4 #include "core/siril.h"
5 #ifdef HAVE_LIBTIFF
6 #define uint64 uint64_hack_
7 #define int64 int64_hack_
8 #include <tiffio.h>
9 #undef uint64
10 #undef int64
11 #endif
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 /****************** image_formats_internal.h ******************/
18 /* BMP */
19 int readbmp(const char*, fits*);
20 int savebmp(const char*, fits*);
21 
22 /* PNM */
23 int import_pnm_to_fits(const char *filename, fits *fit);
24 int saveNetPBM(const char *name, fits *fit);
25 
26 /* PIC */
27 struct pic_struct {
28 	unsigned long magic;
29 	unsigned short width;
30 	unsigned short height;
31 	unsigned short bin[6];
32 	unsigned short nbplane;
33 	unsigned short hi;
34 	unsigned short lo;
35 	char *date;
36 	char *time;
37 
38 	// internal stuff
39 	FILE *file;
40 };
41 int readpic(const char *name, fits *fit);
42 
43 /****************** image_formats_libraries.h ******************/
44 #ifdef HAVE_LIBTIFF
45 int readtif(const char *name, fits *fit, gboolean force_float);
46 int savetif(const char *name, fits *fit, uint16_t bitspersample);
47 #endif
48 
49 #ifdef HAVE_LIBJPEG
50 int readjpg(const char*, fits*);
51 int savejpg(const char*, fits*, int);
52 #endif
53 
54 #ifdef HAVE_LIBPNG
55 int readpng(const char*, fits*);
56 int savepng(const char *filename, fits *fit, uint32_t bytes_per_sample,
57 		gboolean is_colour);
58 #endif
59 
60 #ifdef HAVE_LIBRAW
61 int open_raw_files(const char*, fits*, gboolean);
62 #endif
63 
64 #ifdef HAVE_LIBHEIF
65 int readheif(const char* name, fits *fit, gboolean interactive);
66 #endif
67 
68 /****************** utils.h ******************/
69 int round_to_int(double x);
70 int roundf_to_int(float x);
71 WORD round_to_WORD(double x);
72 BYTE round_to_BYTE(double x);
73 BYTE roundf_to_BYTE(float f);
74 WORD roundf_to_WORD(float f);
75 int round_to_ceiling_multiple(int x, int factor);
76 BYTE conv_to_BYTE(double x);
77 int truncate_to_int32(uint64_t x);
78 WORD truncate_to_WORD(int x);
79 int set_int_in_interval(int val, int low, int high);
80 float set_float_in_interval(float val, float low, float high);
81 double set_double_in_interval(double val, double low, double high);
82 float ushort_to_float_range(WORD w);
83 float uchar_to_float_range(BYTE w);
84 float double_ushort_to_float_range(double d);
85 WORD float_to_ushort_range(float f);
86 BYTE float_to_uchar_range(float f);
87 float ushort_to_float_bitpix(fits *fit, WORD value);
88 WORD *float_buffer_to_ushort(float *buffer, size_t ndata);
89 float *uchar_buffer_to_float(BYTE *buffer, size_t ndata);
90 float *ushort_buffer_to_float(WORD *buffer, size_t ndata);
91 float *ushort8_buffer_to_float(WORD *buffer, size_t ndata);
92 gboolean test_double_eq(double a, double b, double epsilon);
93 uint16_t change_endianness16(uint16_t x);
94 uint16_t cpu_to_le16(uint16_t x);
95 uint16_t cpu_to_be16(uint16_t x);
96 uint16_t le16_to_cpu(uint16_t x);
97 uint16_t be16_to_cpu(uint16_t x);
98 uint32_t change_endianness32(uint32_t x);
99 uint32_t cpu_to_le32(uint32_t x);
100 uint32_t cpu_to_be32(uint32_t x);
101 uint32_t le32_to_cpu(uint32_t x);
102 uint32_t be32_to_cpu(uint32_t x);
103 uint64_t change_endianness64(uint64_t x);
104 uint64_t cpu_to_le64(uint64_t x);
105 uint64_t cpu_to_be64(uint64_t x);
106 uint64_t le64_to_cpu(uint64_t x);
107 uint64_t be64_to_cpu(uint64_t x);
108 gboolean isrgb(fits *fit);
109 int get_extension_index(const char *filename);
110 image_type get_type_from_filename(const gchar *filename);
111 char* remove_ext_from_filename(const char *basename);
112 gchar *replace_ext(const char *path, const char *new_ext);
113 gboolean string_is_a_path(const char *file);
114 int is_readable_file(const char *filename);
115 gboolean is_forbiden_in_filename(gchar c);
116 gboolean file_name_has_invalid_chars(const char *name);
117 int stat_file(const char *filename2, image_type *type, char **realname);
118 const char* get_filename_ext(const char *filename);
119 
120 int siril_change_dir(const char *dir, gchar **err);
121 gchar* get_locale_filename(const gchar *path);
122 int update_sequences_list(const char *sequence_name_to_select);
123 void expand_home_in_filename(char *filename, int size);
124 double get_normalized_value(fits*);
125 void swap_param(double*, double*);
126 gchar* str_append(char **data, const char *newdata);
127 char *format_basename(char *root, gboolean can_free);
128 float compute_slope(WORD *lo, WORD *hi);
129 gchar *siril_get_file_info(const gchar *filename, GdkPixbuf *pixbuf);
130 gchar *siril_truncate_str(gchar *str, gint size);
131 char **glist_to_array(GList *list, int *arg_count);
132 gchar* url_cleanup(const gchar *uri_string);
133 
134 /****************** quantize.h ***************/
135 int siril_fits_img_stats_ushort(WORD *array, long nx, long ny, int nullcheck,
136 		WORD nullvalue, long *ngoodpix, WORD *minvalue, WORD *maxvalue,
137 		double *mean, double *sigma, double *noise1, double *noise2,
138 		double *noise3, double *noise5, gboolean multithread, int *status);
139 
140 int siril_fits_img_stats_float(float *array, long nx, long ny, int nullcheck,
141 		float nullvalue, long *ngoodpix, float *minvalue, float *maxvalue,
142 		double *mean, double *sigma, double *noise1, double *noise2,
143 		double *noise3, double *noise5, gboolean multithread, int *status);
144 
145 /****************** siril.h ******************/
146 
147 int threshlo(fits *fit, WORD level);
148 int threshhi(fits *fit, WORD level);
149 int nozero(fits *fit, WORD level);
150 int unsharp(fits*, double sigma, double mult, gboolean verbose);
151 float entropy(fits *fit, int layer, rectangle *area, imstats *opt_stats);
152 int loglut(fits *fit);
153 int ddp(fits *a, int lev, float coef, float sig);
154 int visu(fits *fit, int low, int high);
155 int fill(fits *fit, int level, rectangle *arearg);
156 int off(fits *a, float level);
157 double background(fits *fit, int reqlayer, rectangle *selection, gboolean multithread);
158 void show_FITS_header(fits*);
159 void compute_grey_flat(fits *fit);
160 
161 /****************** seqfile.h ******************/
162 sequence* readseqfile(const char *name);
163 int writeseqfile(sequence *seq);
164 gboolean existseq(const char *name);
165 int buildseqfile(sequence *seq, int force_recompute);
166 
167 /****************** registration_preview.h ******************/
168 void redraw_previews();
169 void set_preview_area(int preview_area, int centerX, int centerY);
170 void init_mouse();
171 void adjust_reginfo();
172 void on_spinbut_shift_value_change(GtkSpinButton *spinbutton,
173 		gpointer user_data);
174 void test_and_allocate_reference_image(int vport);
175 void enable_view_reference_checkbox(gboolean status);
176 
177 /****************** statistics_list.h ******************/
178 void computeStat();
179 
180 /****************** siril_log.h ******************/
181 char* siril_log_message(const char* format, ...);
182 char* siril_log_color_message(const char* format, const char* color, ...);
183 
184 #ifdef __cplusplus
185 }
186 #endif
187 
188 #endif
189