File: utils.h

package info (click to toggle)
xmorph 1%3A20011220
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,468 kB
  • ctags: 1,534
  • sloc: ansic: 16,401; sh: 2,651; makefile: 556; tcl: 516
file content (201 lines) | stat: -rw-r--r-- 3,951 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

#define dstmesh  (&(sp->im_mesh[MAX_WINS + 1]))

/* color for selected points */
extern GdkGC   *mps_gc;
/* color for resulting points */
extern GdkGC   *mpr_gc;
/* color for mesh lines */
extern GdkGC *mpl_gc;

void allocate_colors(GtkWidget * widget);




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

void
destroy_image_win_data(int lp);

void
alloc_image_win_data(int lp);

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_editshow(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(int lp, char * r, char *g, char * b);


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

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


/**********************************************************
 * 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
		 );



/* load/save hooks  */ 

typedef gboolean (*fileselection_hook_t)      (int lp,  char *file);

gboolean load_image_from_file(int lp,
			      char *file);

gboolean save_image_to_file(int lp,
			    char *file);

gboolean save_mesh_to_file(int lp, char * file);

gboolean load_mesh_from_file(int lp, char * file);




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

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

   */
#define PIXLOADED 0 
#define PIXSUBIMAGE 1
#define PIXWARPED 2

GdkPixbuf **
which_pixbuf_is_visible(int lp);

GdkPixmap **
which_pixmap_is_visible(int lp);

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

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

static inline void
which_pixbuf_size(int lp, int 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, int what);

void
create_pixmap_(int lp, int 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, int 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);

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


setup_handlebox_factors()

if there is only one image , then we may only warp it
so the handlebox is hidden

otherwise they are shown, and the user may set the factors and warp the image

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

void
setup_handlebox_factors();