File: utils.h

package info (click to toggle)
xmorph 1%3A20050408b
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 5,712 kB
  • ctags: 2,109
  • sloc: ansic: 24,471; sh: 11,182; cpp: 1,546; makefile: 954; sed: 16
file content (232 lines) | stat: -rw-r--r-- 4,856 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#ifndef __UTILS_H__
#define __UTILS_H__
#include "main.h"

//CHE CRETINO CHE SONO #define dstmesh  (&(sp->im_mesh[MAIN_WIN]))

/* color for selected points */
extern GdkGC   *mps_gc;
/* color for resulting points */
extern GdkGC   *mpr_gc;
/* color for mesh lines */
extern GdkGC   *mpl_gc;
extern int features_max_n;
extern GdkGC  *features_gc[];

void allocate_colors(GtkWidget * widget);

void set_sensitive(GtkWidget * widget, gboolean flag);


/* void */
/* flash_point(GdkDrawable  *drawable, */
/* 	    int x,int y	    ); */

void
destroy_image_win_pixbufs(int lp, int what);
void
destroy_image_win_data(int lp);

void
alloc_image_win_data(int lp, int what);

void
create_and_show_image_win(int lp);

void
init_image_win_data_and_set_all(int lp, /* the slot where the data are put
					   in the arrays in sp-> */
				GtkWidget * topw, /* the top window */
				char * name);


void
editview_callback(int i);

void
set_editview(int lp, /* window number */
	     int status);



void
pixbuf_to_rrrgggbb(GdkPixbuf *pb, guint8 *r, guint8 *g, guint8 *b);


/* void */
/* rrrgggbbb_add_to_pixbuf(GdkPixbuf *pb, /\* destination *\/ */
/* 			const guint8 *r, const  guint8 *g, const guint8 *b, */
/* 			/\* source *\/ */
/* 			double factor /\* dissolving factor *\/ */
/* 			); */

void
do_warp_an_image_old(int lp); //, char * r, char *g, char * b);

void
do_warp_an_image_new(int lp);

#define do_warp_an_image do_warp_an_image_new

/**********   showerr()
 *  shows libc error 
 */

inline  void 
showerr(const char *file, const  char *msg);


inline static gboolean mesh_need_saving(int lp)
{
  return sp->im_widget[lp] && sp->im_mesh[lp].changed>0;
}

/* did the user use it somehow?  */
inline static gboolean image_used(int lp)
{
  return sp->im_widget[lp] && ( sp->im_mesh_filename[lp] ||
				sp->im_mesh[lp].changed>0 ||
				sp->im_filename_in[lp] || 
				sp->im_filename_out[lp]);
}



/**********************************************************
 * accepts new backing pixmap of the appropriate size 
 *  save it in the data of the top window 
 * and in the sp-> structure
 * resizes the viewport
*/

gboolean
set_backing_pixmap        (GtkWidget       *widget,
		   GdkPixmap *newpixmap,
		   int width, int height);



/********************************************************************
		loads image from pixbuf to pixmap for image window "lp"
		you should unref the pixbuf   when it exists
		
		copies its data to r,g,b,
*/


void scale_loaded_pixbuf_to_pixmap_et_rrggbb(
					     // GdkPixbuf      *impixold,
		 int lp //image number
		 );



/****************************************************************************
 promote meshes to have same lines and columns 
***************************************************************************/

void promote_meshes();
/***********************************************************************
 which image are we displaying? 

   */
enum what_display{ PIXLOADED=0, PIXSUBIMAGE=1, 
		   PIXWARPED=2};

GdkPixbuf **
which_pixbuf_is_visible(int lp);

GdkPixmap **
which_pixmap_is_visible(int lp);

GdkPixbuf **
which_pixbuf(int lp, enum what_display what);

GdkPixmap **
which_pixmap(int lp, enum what_display what);


void
destroy_pixbuf(int lp, enum what_display what);

void
destroy_pixmap(int lp, enum what_display what);

#define PIXLOADEDBORDER 100
#define PIXEDITBORDER 30

static inline void
which_pixbuf_size(int lp, enum what_display what, int *w, int *h)
{
  *w=sp->resulting_width; *h=sp->resulting_height;
  if(what == PIXLOADED)
    { *w=sp->im_width[lp] ;  *h=sp->im_height[lp]; }
}


void
create__pixbuf(int lp, enum what_display what);

void
create__pixmap(int lp, enum what_display what);

static inline void
which_pixbuf_size_is_visible(int lp, int *w, int *h)
{
  which_pixbuf_size( lp,sp->which_pix[lp] , w, h);
}


void 
render_pixmap(int lp, enum what_display what);

/***************************************************************

 *		drawing area bookkeeping

 ***********************************************************
*/ 


/* creates new backing pixmap of the appropriate size 
   save it in the data of the top window

   it uses: the image filename, to load the image, or, if none
   it creates a black pixmap

   it sets what is necessary for properly displaying the
   drawing area*/


void
drawingarea_configure (int i);

void
reload_and_scale_image(int i);


void
setup_handlebox_factors();
void
setup_handlebox_factor(int lp, int force);



void   set_frame_label(int i);




#ifdef GDK_PIXBUF_MAJOR /* interfaces accepting GdkPixbufs */
#include "libmorph/warp2.h"
void warp_image_gdk_a
( GdkPixbuf *src, GdkPixbuf *dst,
  const double *xs, const double *ys, const double *xd, const double *yd,
  int mesh_width, int mesh_height);

void warp_image_gdk_m
( GdkPixbuf *src, GdkPixbuf *dst,
  MeshT *srcmesh, MeshT *dstmesh);
#endif

#endif //__UTILS_H__