1double sin(double x);
2double cos(double x);
3double tan(double x);
4double asin(double x);
5double acos(double x);
6double atan(double x);
7double atan2(double y, double x);
8double sinh(double x);
9double cosh(double x);
10double tanh(double x);
11double exp(double x);
12double expm1(double x);
13double log(double x);
14double log10(double x);
15double log1p(double x);
16double pow(double x, double y);
17double sqrt(double x);
18double cbrt(double x);
19double ceil(double x);
20double floor(double x);
21double fabs(double x);
22double frexp(double value, int *eptr);
23double ldexp(double value, int exp);
24double modf(double value, double *iptr);
25double erf(double x);
26double erfc(double x);
27double atof(const char *nptr);
28double hypot(double x, double y);
29double lgamma(double x);
30double j0(double x);
31double j1(double x);
32double jn(int n, double x);
33double y0(double x);
34double y1(double x);
35double yn(int n, double x);
36extern struct _iobuf {
37 int _cnt;
38 char *_ptr;
39 char *_base;
40 int _bufsiz;
41 short _flag;
42 char _file;
43} _iob[];
44typedef __SIZE_TYPE__ size_t;
45typedef char *va_list;
46struct _iobuf *fopen(const char *filename, const char *type);
47struct _iobuf *freopen(const char *filename, const char *type, struct _iobuf *stream);
48struct _iobuf *fdopen(int fildes, const char *type);
49struct _iobuf *popen(const char *command, const char *type);
50int pclose(struct _iobuf *stream);
51int fflush(struct _iobuf *stream);
52int fclose(struct _iobuf *stream);
53int remove(const char *path);
54int rename(const char *from, const char *to);
55struct _iobuf *tmpfile(void);
56char *tmpnam(char *s);
57int setvbuf(struct _iobuf *iop, char *buf, int type, size_t size);
58int setbuf(struct _iobuf *stream, char *buf);
59int setbuffer(struct _iobuf *stream, char *buf, size_t size);
60int setlinebuf(struct _iobuf *stream);
61int fprintf(struct _iobuf *stream, const char *format, ...);
62int printf(const char *format, ...);
63char *sprintf(char *s, const char *format, ...);
64int vfprintf(struct _iobuf *stream, const char *format, va_list arg);
65int vprintf(const char *format, va_list arg);
66int vsprintf(char *s, const char *format, va_list arg);
67int fscanf(struct _iobuf *stream, const char *format, ...);
68int scanf(const char *format, ...);
69int sscanf(char *s, const char *format, ...);
70int fgetc(struct _iobuf *stream);
71int getw(struct _iobuf *stream);
72char *fgets(char *s, int n, struct _iobuf *stream);
73char *gets(char *s);
74int fputc(int c, struct _iobuf *stream);
75int putw(int w, struct _iobuf *stream);
76int fputs(const char *s, struct _iobuf *stream);
77int puts(const char *s);
78int ungetc(int c, struct _iobuf *stream);
79int fread(void *ptr, size_t size, size_t count, struct _iobuf *iop);
80int fwrite(const void *ptr, size_t size, size_t count, struct _iobuf *iop);
81int fseek(struct _iobuf *stream, long offset, int ptrname);
82long ftell(struct _iobuf *stream);
83void rewind(struct _iobuf *stream);
84int fgetpos(struct _iobuf *stream, long *pos);
85int fsetpos(struct _iobuf *stream, const long *pos);
86void perror(const char *s);
87typedef unsigned char byte;
88typedef unsigned char uchar;
89typedef unsigned short ushort;
90typedef unsigned int uint;
91typedef unsigned long ulong;
92typedef unsigned char u_char;
93typedef unsigned short u_short;
94typedef unsigned int u_int;
95typedef unsigned long u_long;
96typedef unsigned short ushort_;
97typedef struct _physadr { int r[1]; } *physadr;
98typedef struct label_t {
99 int val[11];
100} label_t;
101typedef struct _quad { long val[2]; } quad;
102typedef long daddr_t;
103typedef char * caddr_t;
104typedef u_long ino_t;
105typedef long swblk_t;
106typedef long time_t;
107typedef short dev_t;
108typedef long off_t;
109typedef u_short uid_t;
110typedef u_short gid_t;
111typedef signed char prio_t;
112typedef long fd_mask;
113typedef struct fd_set {
114 fd_mask fds_bits[(((256 )+(( (sizeof(fd_mask) * 8 ) )-1))/( (sizeof(fd_mask) * 8 ) )) ];
115} fd_set;
116typedef struct qhdr {
117 struct qhdr *link, *rlink;
118} *queue_t;
119typedef char *ptr_ord_t;
120typedef double floatp;
121typedef char *(*proc_alloc_t)(unsigned num_elements, unsigned element_size, const char *client_name );
122typedef void (*proc_free_t)(char *data, unsigned num_elements, unsigned element_size, const char *client_name );
123extern struct _iobuf *gs_out;
124typedef struct gs_point_s {
125 double x, y;
126} gs_point;
127typedef struct gs_int_point_s {
128 int x, y;
129} gs_int_point;
130typedef struct gs_rect_s {
131 gs_point p, q;
132} gs_rect;
133typedef struct gs_int_rect_s {
134 gs_int_point p, q;
135} gs_int_rect;
136typedef struct gs_state_s gs_state;
137typedef struct {
138 proc_alloc_t alloc;
139 proc_free_t free;
140} gs_memory_procs;
141char *gs_malloc(uint, uint, const char * );
142void gs_free(char *, uint, uint, const char * );
143extern char gs_debug[128];
144extern int gs_log_error(int, const char *, int );
145typedef long fixed;
146typedef struct gs_fixed_point_s {
147 fixed x, y;
148} gs_fixed_point;
149typedef struct gs_fixed_rect_s {
150 gs_fixed_point p, q;
151} gs_fixed_rect;
152typedef struct gs_matrix_s {
153 long _xx; float xx; long _xy; float xy; long _yx; float yx; long _yy; float yy; long _tx; float tx; long _ty; float ty;
154} gs_matrix;
155void gs_make_identity(gs_matrix * );
156int gs_make_translation(floatp, floatp, gs_matrix * ),
157 gs_make_scaling(floatp, floatp, gs_matrix * ),
158 gs_make_rotation(floatp, gs_matrix * );
159int gs_matrix_multiply(const gs_matrix *, const gs_matrix *, gs_matrix * ),
160 gs_matrix_invert(const gs_matrix *, gs_matrix * ),
161 gs_matrix_rotate(const gs_matrix *, floatp, gs_matrix * );
162int gs_point_transform(floatp, floatp, const gs_matrix *, gs_point * ),
163 gs_point_transform_inverse(floatp, floatp, const gs_matrix *, gs_point * ),
164 gs_distance_transform(floatp, floatp, const gs_matrix *, gs_point * ),
165 gs_distance_transform_inverse(floatp, floatp, const gs_matrix *, gs_point * ),
166 gs_bbox_transform_inverse(gs_rect *, gs_matrix *, gs_rect * );
167typedef struct gs_matrix_fixed_s {
168 long _xx; float xx; long _xy; float xy; long _yx; float yx; long _yy; float yy; long _tx; float tx; long _ty; float ty;
169 fixed tx_fixed, ty_fixed;
170} gs_matrix_fixed;
171extern void gs_update_matrix_fixed(gs_matrix_fixed * );
172int gs_point_transform2fixed(gs_matrix_fixed *, floatp, floatp, gs_fixed_point * ),
173 gs_distance_transform2fixed(gs_matrix_fixed *, floatp, floatp, gs_fixed_point * );
174typedef struct {
175 long xx, xy, yx, yy;
176 int skewed;
177 int shift;
178 int max_bits;
179 fixed round;
180} fixed_coeff;
181
182typedef enum {
183 gs_cap_butt = 0,
184 gs_cap_round = 1,
185 gs_cap_square = 2
186} gs_line_cap;
187typedef enum {
188 gs_join_miter = 0,
189 gs_join_round = 1,
190 gs_join_bevel = 2
191} gs_line_join;
192gs_state *gs_state_alloc(proc_alloc_t, proc_free_t );
193int gs_state_free(gs_state * );
194int gs_gsave(gs_state * ),
195 gs_grestore(gs_state * ),
196 gs_grestoreall(gs_state * );
197gs_state *gs_gstate(gs_state * );
198int gs_currentgstate(gs_state * , const gs_state * ),
199 gs_setgstate(gs_state * , const gs_state * );
200gs_state *gs_state_swap_saved(gs_state *, gs_state * );
201void gs_state_swap(gs_state *, gs_state * );
202int gs_initgraphics(gs_state * );
203typedef struct gx_device_s gx_device;
204int gs_flushpage(gs_state * );
205int gs_copypage(gs_state * );
206int gs_output_page(gs_state *, int, int );
207int gs_copyscanlines(gx_device *, int, byte *, uint, int *, uint * );
208gx_device * gs_getdevice(int );
209int gs_copydevice(gx_device **, gx_device *, proc_alloc_t );
210int gs_makeimagedevice(gx_device **, gs_matrix *, uint, uint, byte *, int, proc_alloc_t );
211void gs_nulldevice(gs_state * );
212int gs_setdevice(gs_state *, gx_device * );
213gx_device * gs_currentdevice(gs_state * );
214const char * gs_devicename(gx_device * );
215void gs_deviceinitialmatrix(gx_device *, gs_matrix * );
216int gs_closedevice(gx_device * );
217int gs_setlinewidth(gs_state *, floatp );
218float gs_currentlinewidth(const gs_state * );
219int gs_setlinecap(gs_state *, gs_line_cap );
220gs_line_cap gs_currentlinecap(const gs_state * );
221int gs_setlinejoin(gs_state *, gs_line_join );
222gs_line_join gs_currentlinejoin(const gs_state * );
223int gs_setmiterlimit(gs_state *, floatp );
224float gs_currentmiterlimit(const gs_state * );
225int gs_setdash(gs_state *, const float *, uint, floatp );
226uint gs_currentdash_length(const gs_state * );
227int gs_currentdash_pattern(const gs_state *, float * );
228float gs_currentdash_offset(const gs_state * );
229int gs_setflat(gs_state *, floatp );
230float gs_currentflat(const gs_state * );
231int gs_setstrokeadjust(gs_state *, int );
232int gs_currentstrokeadjust(const gs_state * );
233typedef enum {
234 gs_color_space_DeviceGray = 0,
235 gs_color_space_DeviceRGB,
236 gs_color_space_DeviceCMYK
237} gs_color_space;
238typedef struct gs_color_s gs_color;
239extern const uint gs_color_sizeof;
240int gs_setgray(gs_state *, floatp );
241float gs_currentgray(gs_state * );
242int gs_sethsbcolor(gs_state *, floatp, floatp, floatp ),
243 gs_currenthsbcolor(gs_state *, float [3] ),
244 gs_setrgbcolor(gs_state *, floatp, floatp, floatp ),
245 gs_currentrgbcolor(gs_state *, float [3] );
246int gs_currentcolorspace(gs_state *, gs_color_space * );
247typedef float (*gs_transfer_proc)(gs_state *, floatp );
248int gs_settransfer(gs_state *, gs_transfer_proc ),
249 gs_settransfer_remap(gs_state *, gs_transfer_proc, int );
250gs_transfer_proc gs_currenttransfer(gs_state * );
251int gs_setcolortransfer(gs_state *, gs_transfer_proc ,
252 gs_transfer_proc , gs_transfer_proc ,
253 gs_transfer_proc ),
254 gs_setcolortransfer_remap(gs_state *, gs_transfer_proc ,
255 gs_transfer_proc , gs_transfer_proc ,
256 gs_transfer_proc , int );
257void gs_currentcolortransfer(gs_state *, gs_transfer_proc [4] );
258int gs_setscreen(gs_state *, floatp, floatp, float (*)(floatp, floatp ) );
259int gs_currentscreen(gs_state *, float *, float *, float (**)(floatp, floatp ) );
260int gs_sethalftonephase(gs_state *, int, int );
261int gs_currenthalftonephase(gs_state *, gs_int_point * );
262typedef struct gs_screen_enum_s gs_screen_enum;
263extern const uint gs_screen_enum_sizeof;
264int gs_screen_init(gs_screen_enum *, gs_state *, floatp, floatp );
265int gs_screen_currentpoint(gs_screen_enum *, gs_point * );
266int gs_screen_next(gs_screen_enum *, floatp );
267struct gs_state_s {
268 gs_state *saved;
269 gs_memory_procs memory_procs;
270 gs_matrix_fixed ctm;
271 gs_matrix ctm_inverse;
272 int inverse_valid;
273 struct gx_path_s *path;
274 struct gx_clip_path_s *clip_path;
275 int clip_rule;
276 struct line_params_s *line_params;
277 struct halftone_params_s *halftone;
278 float (*ht_proc)(floatp, floatp );
279 gs_int_point ht_phase;
280 gs_int_point phase_mod;
281 struct gs_color_s *color;
282 struct gx_device_color_s *dev_color;
283 struct gx_transfer_s *transfer;
284 struct gs_font_s *font;
285 gs_matrix char_tm;
286 int char_tm_valid;
287 byte in_cachedevice;
288 byte in_charpath;
289
290
291
292
293 int level;
294 float flatness;
295 int stroke_adjust;
296 struct device_s *device;
297 int device_is_shared;
298
299};
300typedef unsigned long gx_bitmap_id;
301typedef struct gx_bitmap_s {
302 byte *data;
303 int raster;
304 gs_int_point size;
305 gx_bitmap_id id;
306 ushort rep_width, rep_height;
307} gx_bitmap;
308typedef unsigned long gx_color_index;
309typedef unsigned short gx_color_value;
310typedef struct gx_device_color_info_s {
311 int num_components;
312
313 int depth;
314 gx_color_value max_gray;
315 gx_color_value max_rgb;
316
317 gx_color_value dither_gray;
318 gx_color_value dither_rgb;
319
320} gx_device_color_info;
321typedef struct gx_device_procs_s gx_device_procs;
322struct gx_device_s {
323 int params_size; gx_device_procs *procs; const char *dname; int width; int height; float x_pixels_per_inch; float y_pixels_per_inch; float l_margin, b_margin, r_margin, t_margin; gx_device_color_info color_info; int is_open;
324};
325typedef struct gs_prop_item_s gs_prop_item;
326struct gx_device_procs_s {
327 int (*open_device)(gx_device *dev );
328 void (*get_initial_matrix)(gx_device *dev, gs_matrix *pmat );
329 int (*sync_output)(gx_device *dev );
330 int (*output_page)(gx_device *dev, int num_copies, int flush );
331 int (*close_device)(gx_device *dev );
332 gx_color_index (*map_rgb_color)(gx_device *dev, gx_color_value red, gx_color_value green, gx_color_value blue );
333 int (*map_color_rgb)(gx_device *dev, gx_color_index color, gx_color_value rgb[3] );
334 int (*fill_rectangle)(gx_device *dev, int x, int y, int width, int height, gx_color_index color );
335 int (*tile_rectangle)(gx_device *dev, gx_bitmap *tile, int x, int y, int width, int height, gx_color_index color0, gx_color_index color1, int phase_x, int phase_y );
336 int (*copy_mono)(gx_device *dev, unsigned char *data, int data_x, int raster, gx_bitmap_id id, int x, int y, int width, int height, gx_color_index color0, gx_color_index color1 );
337 int (*copy_color)(gx_device *dev, unsigned char *data, int data_x, int raster, gx_bitmap_id id, int x, int y, int width, int height );
338 int (*draw_line)(gx_device *dev, int x0, int y0, int x1, int y1, gx_color_index color );
339 int (*get_bits)(gx_device *dev, int y, unsigned char *data, unsigned int size, int pad_to_word );
340 int (*get_props)(gx_device *dev, gs_prop_item *plist );
341
342 int (*put_props)(gx_device *dev, gs_prop_item *plist, int count );
343
344};
345extern unsigned int gx_device_bytes_per_scan_line(gx_device *dev, int pad_to_word );
346int gx_default_open_device(gx_device *dev );
347void gx_default_get_initial_matrix(gx_device *dev, gs_matrix *pmat );
348int gx_default_sync_output(gx_device *dev );
349int gx_default_output_page(gx_device *dev, int num_copies, int flush );
350int gx_default_close_device(gx_device *dev );
351gx_color_index gx_default_map_rgb_color(gx_device *dev, gx_color_value red, gx_color_value green, gx_color_value blue );
352int gx_default_map_color_rgb(gx_device *dev, gx_color_index color, gx_color_value rgb[3] );
353int gx_default_tile_rectangle(gx_device *dev, gx_bitmap *tile, int x, int y, int width, int height, gx_color_index color0, gx_color_index color1, int phase_x, int phase_y );
354int gx_default_copy_color(gx_device *dev, unsigned char *data, int data_x, int raster, gx_bitmap_id id, int x, int y, int width, int height );
355int gx_default_draw_line(gx_device *dev, int x0, int y0, int x1, int y1, gx_color_index color );
356int gx_default_get_bits(gx_device *dev, int y, unsigned char *data, unsigned int size, int pad_to_word );
357int gx_default_get_props(gx_device *dev, gs_prop_item *plist );
358int gx_default_put_props(gx_device *dev, gs_prop_item *plist, int count );
359typedef struct device_s {
360 gx_device *info;
361 int is_band_device;
362 gx_color_index white, black;
363} device;
364int gs_initmatrix(gs_state * ),
365 gs_defaultmatrix(const gs_state *, gs_matrix * ),
366 gs_currentmatrix(const gs_state *, gs_matrix * ),
367 gs_setmatrix(gs_state *, const gs_matrix * ),
368 gs_translate(gs_state *, floatp, floatp ),
369 gs_scale(gs_state *, floatp, floatp ),
370 gs_rotate(gs_state *, floatp ),
371 gs_concat(gs_state *, const gs_matrix * );
372int gs_transform(gs_state *, floatp, floatp, gs_point * ),
373 gs_dtransform(gs_state *, floatp, floatp, gs_point * ),
374 gs_itransform(gs_state *, floatp, floatp, gs_point * ),
375 gs_idtransform(gs_state *, floatp, floatp, gs_point * );
376static int
377ctm_set_inverse(gs_state *pgs)
378{ int code = gs_matrix_invert(&*(gs_matrix *)&(pgs)->ctm , &pgs->ctm_inverse);
379 0;
380 if ( code < 0 ) return code;
381 pgs->inverse_valid = 1;
382 return 0;
383}
384void
385gs_update_matrix_fixed(gs_matrix_fixed *pmat)
386{ (*pmat). tx = ((float)(((*pmat). tx_fixed = ((fixed)(((*pmat). tx)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , (*pmat). ty = ((float)(((*pmat). ty_fixed = ((fixed)(((*pmat). ty)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) )));
387}
388int
389gs_initmatrix(gs_state *pgs)
390{ gx_device *dev = pgs->device->info;
391 (*dev->procs->get_initial_matrix)(dev, &*(gs_matrix *)&(pgs)->ctm );
392 (pgs->ctm). tx = ((float)(((pgs->ctm). tx_fixed = ((fixed)(((pgs->ctm). tx)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , (pgs->ctm). ty = ((float)(((pgs->ctm). ty_fixed = ((fixed)(((pgs->ctm). ty)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , pgs->inverse_valid = 0, pgs->char_tm_valid = 0;
393 return 0;
394}
395int
396gs_defaultmatrix(const gs_state *pgs, gs_matrix *pmat)
397{ gx_device *dev = pgs->device->info;
398 (*dev->procs->get_initial_matrix)(dev, pmat);
399 return 0;
400}
401int
402gs_currentmatrix(const gs_state *pgs, gs_matrix *pmat)
403{ *pmat = *(gs_matrix *)&(pgs)->ctm;
404 return 0;
405}
406int
407gs_setmatrix(gs_state *pgs, const gs_matrix *pmat)
408{ *(gs_matrix *)&(pgs)->ctm = *pmat;
409 (pgs->ctm). tx = ((float)(((pgs->ctm). tx_fixed = ((fixed)(((pgs->ctm). tx)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , (pgs->ctm). ty = ((float)(((pgs->ctm). ty_fixed = ((fixed)(((pgs->ctm). ty)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , pgs->inverse_valid = 0, pgs->char_tm_valid = 0;
410 return 0;
411}
412int
413gs_translate(gs_state *pgs, floatp dx, floatp dy)
414{ gs_point pt;
415 int code;
416 if ( (code = gs_distance_transform(dx, dy, &*(gs_matrix *)&(pgs)->ctm , &pt)) < 0 )
417 return code;
418 pgs->ctm.tx += pt.x;
419 pgs->ctm.ty += pt.y;
420 (pgs->ctm). tx = ((float)(((pgs->ctm). tx_fixed = ((fixed)(((pgs->ctm). tx)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , (pgs->ctm). ty = ((float)(((pgs->ctm). ty_fixed = ((fixed)(((pgs->ctm). ty)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , pgs->inverse_valid = 0, pgs->char_tm_valid = 0;
421 return 0;
422}
423int
424gs_scale(gs_state *pgs, floatp sx, floatp sy)
425{ pgs->ctm.xx *= sx;
426 pgs->ctm.xy *= sx;
427 pgs->ctm.yx *= sy;
428 pgs->ctm.yy *= sy;
429 pgs->inverse_valid = 0, pgs->char_tm_valid = 0;
430 return 0;
431}
432int
433gs_rotate(gs_state *pgs, floatp ang)
434{ int code = gs_matrix_rotate(&*(gs_matrix *)&(pgs)->ctm , ang, &*(gs_matrix *)&(pgs)->ctm );
435 pgs->inverse_valid = 0, pgs->char_tm_valid = 0;
436 return code;
437}
438int
439gs_concat(gs_state *pgs, const gs_matrix *pmat)
440{ int code = gs_matrix_multiply(pmat, &*(gs_matrix *)&(pgs)->ctm , &*(gs_matrix *)&(pgs)->ctm );
441 (pgs->ctm). tx = ((float)(((pgs->ctm). tx_fixed = ((fixed)(((pgs->ctm). tx)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , (pgs->ctm). ty = ((float)(((pgs->ctm). ty_fixed = ((fixed)(((pgs->ctm). ty)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , pgs->inverse_valid = 0, pgs->char_tm_valid = 0;
442 return code;
443}
444int
445gs_transform(gs_state *pgs, floatp x, floatp y, gs_point *pt)
446{ return gs_point_transform(x, y, &*(gs_matrix *)&(pgs)->ctm , pt);
447}
448int
449gs_dtransform(gs_state *pgs, floatp dx, floatp dy, gs_point *pt)
450{ return gs_distance_transform(dx, dy, &*(gs_matrix *)&(pgs)->ctm , pt);
451}
452int
453gs_itransform(gs_state *pgs, floatp x, floatp y, gs_point *pt)
454{
455
456 if ( !!(((*(long *)(&((&pgs->ctm)->xy)) | *(long *)(&( (&pgs->ctm)->yx)) ) << 1) == 0) )
457 { return gs_point_transform_inverse(x, y, &*(gs_matrix *)&(pgs)->ctm , pt);
458 }
459 else
460 { if ( !pgs->inverse_valid ) { int code = ctm_set_inverse(pgs); if ( code < 0 ) return code; };
461 return gs_point_transform(x, y, &pgs->ctm_inverse, pt);
462 }
463}
464int
465gs_idtransform(gs_state *pgs, floatp dx, floatp dy, gs_point *pt)
466{
467
468 if ( !!(((*(long *)(&((&pgs->ctm)->xy)) | *(long *)(&( (&pgs->ctm)->yx)) ) << 1) == 0) )
469 { return gs_distance_transform_inverse(dx, dy,
470 &*(gs_matrix *)&(pgs)->ctm , pt);
471 }
472 else
473 { if ( !pgs->inverse_valid ) { int code = ctm_set_inverse(pgs); if ( code < 0 ) return code; };
474 return gs_distance_transform(dx, dy, &pgs->ctm_inverse, pt);
475 }
476}
477int
478gs_translate_to_fixed(register gs_state *pgs, fixed px, fixed py)
479{ pgs->ctm.tx = ((float)((pgs->ctm.tx_fixed = px)*(1.0/(1<<12 ) )));
480 pgs->ctm.ty = ((float)((pgs->ctm.ty_fixed = py)*(1.0/(1<<12 ) )));
481 pgs->inverse_valid = 0;
482 pgs->char_tm_valid = 1;
483 return 0;
484}
485int
486gx_matrix_to_fixed_coeff(const gs_matrix *pmat, register fixed_coeff *pfc,
487 int max_bits)
488{ gs_matrix ctm;
489 int scale = -10000;
490 int expt, shift;
491 ctm = *pmat;
492 pfc->skewed = 0;
493 if ( !((*(long *)(&(ctm.xx)) << 1) == 0) )
494 { (void)frexp(ctm.xx, &scale);
495 }
496 if ( !((*(long *)(&(ctm.xy)) << 1) == 0) )
497 { (void)frexp(ctm.xy, &expt);
498 if ( expt > scale ) scale = expt;
499 pfc->skewed = 1;
500 }
501 if ( !((*(long *)(&(ctm.yx)) << 1) == 0) )
502 { (void)frexp(ctm.yx, &expt);
503 if ( expt > scale ) scale = expt;
504 pfc->skewed = 1;
505 }
506 if ( !((*(long *)(&(ctm.yy)) << 1) == 0) )
507 { (void)frexp(ctm.yy, &expt);
508 if ( expt > scale ) scale = expt;
509 }
510 scale = sizeof(long) * 8 - 1 - max_bits - scale;
511 shift = scale - 12;
512 if ( shift > 0 )
513 { pfc->shift = shift;
514 pfc->round = (fixed)1 << (shift - 1);
515 }
516 else
517 { pfc->shift = 0;
518 pfc->round = 0;
519 scale -= shift;
520 }
521 pfc->xx = (((*(long *)(&(ctm.xx)) << 1) == 0) ? 0 : (long)ldexp(ctm.xx, scale));
522 pfc->yy = (((*(long *)(&(ctm.yy)) << 1) == 0) ? 0 : (long)ldexp(ctm.yy, scale));
523 if ( pfc->skewed )
524 { pfc->xy = (((*(long *)(&(ctm.xy)) << 1) == 0) ? 0 : (long)ldexp(ctm.xy, scale));
525 pfc->yx = (((*(long *)(&(ctm.yx)) << 1) == 0) ? 0 : (long)ldexp(ctm.yx, scale));
526 }
527 else
528 pfc->xy = pfc->yx = 0;
529 pfc->max_bits = max_bits;
530 return 0;
531}
532