Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
Functions
fn_decls.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void init_img_info (image_information *i)
 
void main (int argc, char **argv)
 
void handle_exposure (register image_information *img, int x, int y, int width, int height, int img_h)
 
image_informationaction_flip_forward (image_information *img, image_information *img_info, int flip_book_udelay, int n, unsigned long mask, XEvent *event, Boolean *found_event)
 
image_informationaction_flip_backward (image_information *img, image_information *img_info, int flip_book_udelay, int n, unsigned long mask, XEvent *event, Boolean *found_event)
 
image_informationaction_flip_book_cycle (image_information *img, image_information *img_info, int n, Boolean flip_forward, int flip_book_udelay)
 
int resize_window (image_information *img, int new_w, int new_h)
 
void set_watch_cursor (Window window)
 
void set_circle_cursor (Window window)
 
void set_left_ptr_cursor (Window window)
 
void get_cursors (Window window)
 
XImage * get_X_image (image_information *img, int width, int height, Boolean share)
 
void destroy_X_image (image_information *img, XImage *image)
 
void check_pixmap_allocation (image_information *img)
 
int allocate_ximage (image_information *img, Boolean reallocate)
 
void allocate_pixmap (image_information *img, Boolean reallocate)
 
void free_X_pixmap (image_information *img, Pixmap pix)
 
void put_X_image (image_information *img, Drawable d, GC gc, XImage *image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height)
 
void determine_icon_size (int image_width, int image_height, int *icon_width, int *icon_height, int *icon_factor)
 
void get_x_colormap (image_information *img)
 
void open_x_display (char *display_name)
 
void calc_view_origin (image_information *img)
 
void create_windows (register image_information *img, char *window_geometry)
 
void init_color (register image_information *img)
 
void free_unique_colors (image_information *img, Pixel *pixels, int npixels)
 
void free_image_colors (image_information *img)
 
void find_appropriate_visual (register image_information *img)
 
void MapPixWindow (image_information *img, int use_top)
 
void DrawPixWindow (image_information *img, int x, int y)
 
void DrawSpeedWindow (image_information *img, int s)
 
void UnmapPixWindow (image_information *img)
 
void set_timer (unsigned n)
 
void wait_timer (void)
 
void choose_scanline_converter (image_information *img)
 
void map_rgb_to_bw (image_information *img, rle_pixel **rows, register rle_pixel *bw_row)
 
void map_rgb_to_rgb (image_information *img, rle_pixel **in_rows, rle_pixel **out_rows)
 
void get_dither_arrays (register image_information *img)
 
int shift_match_left (Pixel mask, int high_bit_index)
 
int shift_match_right (Pixel mask)
 
void check_mono_color (image_information *img, rle_hdr *img_hdr)
 
void get_dither_colors (register image_information *img, rle_hdr *img_hdr)
 
int eq_cmap (register rle_pixel **cm1, int len1, register rle_pixel **cm2, int len2)
 
int XCopyImage (XImage *image, int src_x, int src_y, int width, int height, int dst_x, int dst_y)
 
int XAllocColors (register Display *dpy, Colormap cmap, XColor *defs, int ndefs, int *statuses)
 

Function Documentation

image_information* action_flip_backward ( image_information img,
image_information img_info,
int  flip_book_udelay,
int  n,
unsigned long  mask,
XEvent *  event,
Boolean found_event 
)

Definition at line 1377 of file getx11.c.

1384 {
1385  if (mask) *found_event = False;
1386 
1387  if ( img == img_info )
1388  img = &img_info[n - 1];
1389  for ( ; img >= &img_info[0]; img-- ) {
1390  set_timer( flip_book_udelay );
1391  handle_exposure(img, 0, 0, img->w, img->h, img->h);
1392  XFlush( dpy );
1393  if (mask && XCheckMaskEvent(dpy, mask, event )){
1394  *found_event = True;
1395  break;
1396  }
1397  wait_timer();
1398  }
1399  if (mask && *found_event)
1400  return img;
1401  else return img + 1;
1402 }
static unsigned mask
Definition: mcut.c:162
static struct Image img
Definition: getami.c:71
void wait_timer()
Definition: timer.c:72
void set_timer(unsigned n)
Definition: timer.c:46
gpr_ $event_t event
Definition: getap.c:105
void handle_exposure(image_information *img, int x, int y, int width, int height, int img_h)
Definition: getx11.c:577
Display * dpy
Definition: getx11.c:75
image_information* action_flip_book_cycle ( image_information img,
image_information img_info,
int  n,
Boolean  flip_forward,
int  flip_book_udelay 
)

Definition at line 1404 of file getx11.c.

1409 {
1410  int found_event;
1411  XEvent event;
1412 
1413  do {
1414  img = (* (flip_forward ? action_flip_forward : action_flip_backward))
1415  (img, img_info, flip_book_udelay, n, ButtonPressMask|KeyPressMask,
1416  &event, &found_event);
1417  XSync(dpy, False);
1418  } while ( !found_event );
1419  return img;
1420 }
static struct Image img
Definition: getami.c:71
gpr_ $event_t event
Definition: getap.c:105
Display * dpy
Definition: getx11.c:75
image_information * action_flip_forward(image_information *img, image_information *img_info, int flip_book_udelay, int n, unsigned long mask, XEvent *event, Boolean *found_event)
Definition: getx11.c:1350
image_information * img_info
Definition: getx11.c:106
image_information * action_flip_backward(image_information *img, image_information *img_info, int flip_book_udelay, int n, unsigned long mask, XEvent *event, Boolean *found_event)
Definition: getx11.c:1377
image_information* action_flip_forward ( image_information img,
image_information img_info,
int  flip_book_udelay,
int  n,
unsigned long  mask,
XEvent *  event,
Boolean found_event 
)

Definition at line 1350 of file getx11.c.

1357 {
1358  if (mask) *found_event = False;
1359 
1360  if ( img == &img_info[n - 1] )
1361  img = &img_info[0];
1362  for ( ; img < &img_info[n]; img++ ) {
1363  set_timer( flip_book_udelay );
1364  handle_exposure(img, 0, 0, img->w, img->h, img->h);
1365  XFlush( dpy );
1366  if (mask && XCheckMaskEvent(dpy, mask, event )){
1367  *found_event = True;
1368  break;
1369  }
1370  wait_timer();
1371  }
1372  if (mask && *found_event)
1373  return img;
1374  else return img - 1;
1375 }
static unsigned mask
Definition: mcut.c:162
static struct Image img
Definition: getami.c:71
void wait_timer()
Definition: timer.c:72
void set_timer(unsigned n)
Definition: timer.c:46
gpr_ $event_t event
Definition: getap.c:105
void handle_exposure(image_information *img, int x, int y, int width, int height, int img_h)
Definition: getx11.c:577
Display * dpy
Definition: getx11.c:75
void allocate_pixmap ( image_information img,
Boolean  reallocate 
)

Definition at line 325 of file x11_stuff.c.

328 {
329  extern int stingy_flag;
330 
331  int iw = img->w * img->mag_fact;
332  int ih = img->h * img->mag_fact;
333 
334  if (( img->pixmap != NULL && reallocate ) ||
335  ( img->pixmap != NULL && (img->pix_w < iw || img->pix_h < ih ))){
336  free_X_pixmap( dpy, img->pixmap );
337  img->pixmap = NULL;
338  }
339 
340  /* reallocate it: use the Min of the winsize and (pic * mag) */
341  if ( !img->pixmap && !img->pixmap_failed && !stingy_flag) {
342  img->pix_w = Min( iw, img->win_w );
343  img->pix_h = Min( ih, img->win_h );
344 #ifdef X_SHARED_MEMORY
345  img->shm_pix.shmid = -1;
346  if ( use_shared_pixmaps )
347  {
348  XImage *image;
349  XShmSegmentInfo shminfo;
350 
351  /* Allocate an image structure to get bytes_per_line. */
352  image = XShmCreateImage( dpy, img->dpy_visual,
353  img->dpy_depth, ZPixmap,
354  NULL, &shminfo,
355  img->pix_w, img->pix_h );
356  /* Get a shared segment for the pixmap. */
357  img->shm_pix.shmid =
358  shmget( IPC_PRIVATE,
359  image->bytes_per_line * image->height,
360  IPC_CREAT|0777 );
361  XDestroyImage( image );
362  if ( img->shm_pix.shmid < 0 )
363  {
364  if ( errno == ENOSPC )
365  {
366  if ( !no_shared_space )
367  fprintf( stderr,
368  "getx11: No more shared memory segments\n" );
369  no_shared_space = True;
370  }
371  else
372  perror( "getx11: shared memory allocation failed" );
373  }
374  else
375  {
376  /* Attach the segment & get its address. */
377  img->shm_pix.shmaddr = shmat( img->shm_pix.shmid, 0, 0 );
378 
379  if ( img->shm_pix.shmaddr == NULL) {
380  perror ( "getx11: attach shared pixmap" );
381  shmctl( img->shm_pix.shmid, IPC_RMID, 0 );
382  img->shm_pix.shmid = -1;
383  }
384  else
385  {
386  /* Want to write into the segment! */
387  img->shm_pix.readOnly = False;
388 
389  /* Tell the X server about it. */
390  if ( !XShmAttach( dpy, &img->shm_pix ) )
391  {
392  fprintf( stderr, "getx11: XShmAttach failed.\n" );
393  shmdt( img->shm_pix.shmaddr );
394  shmctl( img->shm_pix.shmid, IPC_RMID, 0 );
395  img->shm_pix.shmid = -1;
396  }
397  else
398  {
399  img->pixmap = XShmCreatePixmap(
400  dpy, img->window, img->shm_pix.shmaddr,
401  &img->shm_pix, img->pix_w, img->pix_h,
402  img->dpy_depth );
403  }
404  }
405  }
406  }
407 
408  /* If not sharing, or sharing failed, then try to do it normally. */
409  if ( img->shm_pix.shmid < 0 )
410 #endif /* X_SHARED_MEMORY */
411  img->pixmap = XCreatePixmap(dpy, img->window,
412  img->pix_w, img->pix_h,
413  img->dpy_depth );
415 #ifdef X_SHARED_MEMORY
416  if ( img->shm_pix.shmid >= 0 )
417  {
418  /* Remove it now so it will go when we die.
419  * Another nice side effect: we don't fill up the SHM table,
420  * so we can allocate hundreds of them.
421  */
422  shmctl( img->shm_pix.shmid, IPC_RMID, 0 );
423  }
424 #endif
425  }
426 }
Display * dpy
Definition: getx10.c:94
void free_X_pixmap(image_information *img, Pixmap pix)
Definition: x11_stuff.c:429
Boolean pixmap_failed
Definition: getx11.h:134
Boolean use_shared_pixmaps
Definition: getx11.c:85
XShmSegmentInfo shm_pix
Definition: getx11.h:184
Visual * dpy_visual
Definition: getx11.h:132
void_star shmat()
int stingy_flag
Definition: getx11.c:81
Colorindex * image
Definition: getmex.c:29
void check_pixmap_allocation(image_information *img)
Definition: x11_stuff.c:293
Boolean no_shared_space
Definition: getx11.c:86
#define Min(x, y)
Definition: getx11.h:75
int allocate_ximage ( image_information img,
Boolean  reallocate 
)

Definition at line 301 of file x11_stuff.c.

304 {
305  int iw = img->w * img->mag_fact;
306  int ih = img->h * img->mag_fact;
307 
308  if ( img->image != NULL &&
309  ( reallocate || (img->image->width < iw || img->image->height < ih))) {
310  destroy_X_image( img, img->image );
311  img->image = NULL;
312  }
313  if (img->image == NULL) {
314  int w, h;
315  w = Min( iw, img->win_w );
316  h = Min( ih, img->win_h );
317  img->image = get_X_image( img, w, h, True );
318  }
319  if ( img->image == NULL )
320  perror("problem getting XImage");
321 
322  return( img->image != NULL );
323 }
XImage * get_X_image(image_information *img, int width, int height, Boolean share)
Definition: x11_stuff.c:135
XImage * image
Definition: getx11.h:129
void destroy_X_image(image_information *img, XImage *image)
Definition: x11_stuff.c:238
#define Min(x, y)
Definition: getx11.h:75
void calc_view_origin ( image_information img)

Definition at line 575 of file x11_stuff.c.

577 {
578  img->xo = (img->win_w - (img->w * img->mag_fact)) / 2;
579  img->yo = (img->win_h - (img->h * img->mag_fact)) / 2;
580  img->xo = Max (0, img->xo);
581  img->yo = Max (0, img->yo);
582 }
#define Max(x, y)
Definition: getx11.h:76
void check_mono_color ( image_information img,
rle_hdr img_hdr 
)

Definition at line 32 of file in_cmap.c.

35 {
36  /* Get some info out of the RLE header. */
37  img->ncmap = img_hdr->ncmap;
38  {
39  char * v;
40  if ( (v = rle_getcom( "color_map_length", img_hdr )) != NULL )
41  img->cmlen = atoi( v );
42  else
43  img->cmlen = 1 << img_hdr->cmaplen;
44 
45  /* Protect against bogus information */
46  if ( img->cmlen < 0 )
47  img->cmlen = 0;
48  if ( img->cmlen > 256 )
49  img->cmlen = 256;
50  }
51 
52  /* The mono_color flag means that a single input channel is being
53  * pseudocolored by a multi-channel colormap.
54  */
55  img->mono_color = (img->img_channels == 1 && img->ncmap == 3 &&
56  img->cmlen);
57 
58 }
char * rle_getcom(const char *name, rle_hdr *the_hdr)
Boolean mono_color
Definition: getx11.h:168
int ncmap
Definition: rle.h:100
int cmaplen
Definition: rle.h:100
void check_pixmap_allocation ( image_information img)

Definition at line 293 of file x11_stuff.c.

295 {
296  wait_img = img;
297  XSetErrorHandler( handle_x_errors );
298  XSync( dpy, False );
299 }
Display * dpy
Definition: getx10.c:94
static struct Image img
Definition: getami.c:71
static image_information * wait_img
Definition: x11_stuff.c:61
static int handle_x_errors(Display *dpy, XErrorEvent *event)
Definition: x11_stuff.c:258
void choose_scanline_converter ( image_information img)

Definition at line 77 of file map_scan.c.

79 {
80  register int i;
81  register Boolean table_present;
82  static struct {
83  Boolean one_color;
84  Boolean dither;
85  Boolean table_present;
86  int bpp;
87  void (*routine)();
88  void (*mag_routine)();
89  } map_scanline_table[] =
90  {
91 
92  /* 1 color, dithr, Table, b/p, routine ptr */
93 
94  { True, True, False, 1, map_1_dither_notable_1, MAG_1_dither_notable_1},
95  { True, True, True, 8, map_1_dither_table_8, MAG_1_dither_table_8},
96  { True, False,True, 8, map_1_nodither_table_8, MAG_1_nodither_table_8},
98  { False,True, True, 8, map_2or3_dither_table_8, MAG_2or3_dither_table_8},
102 
105 
106  if (img->pixel_table == NULL)
107  table_present = False;
108  else table_present = True;
109 
110  if (img->mono_color)
111  switch (img->image->bits_per_pixel) {
112  case 32:
115  break;
116  case 8:
119  break;
120  default:
121  fprintf(stderr, "%s: Warning: Bits per pixel = %d\n",
122  progname, img->image->bits_per_pixel);
123  }
124  else
125  for (i = 0; i < COUNT_OF (map_scanline_table); i++) {
126  if (map_scanline_table[i].one_color == img->mono_img &&
127  map_scanline_table[i].dither == img->dither_img &&
128  map_scanline_table[i].table_present == table_present &&
129  map_scanline_table[i].bpp == img->image->bits_per_pixel) {
130  img->map_scanline = map_scanline_table[i].routine;
131  img->MAG_scanline = map_scanline_table[i].mag_routine;
132 
133  if ( verbose_flag ) {
134  fprintf ( stderr, "Special map_scanline routine used: map_");
135 
136  if ( img->mono_img )
137  fputs ( "1_", stderr );
138  else fputs ( "2or3_", stderr );
139 
140  if ( !img->dither_img )
141  fputs ( "no", stderr );
142  fputs ( "dither_", stderr );
143 
144  if (! table_present ) fputs ( "no", stderr );
145  fprintf ( stderr, "table_%d (index %d)\n",
146  img->image->bits_per_pixel, i );
147  }
148  break;
149  }
150  }
151 }
int Boolean
Definition: getx11.h:53
static void map_2or3_dither_table_8()
static void map_2or3_dither_notable_32()
static void map_1_dither_notable_1()
static void MAG_1_nodither_table_8()
static void MAG_1_mono_color_32()
static void MAG_2or3_dither_notable_32()
static void map_1_nodither_table_8()
static void MAG_2or3_nodither_notable_32()
Boolean verbose_flag
Definition: getx11.c:80
static void MAG_1_dither_notable_1()
static void map_1_mono_color_32()
static void map_2or3_nodither_notable_32()
Boolean mono_color
Definition: getx11.h:168
static void map_2or3_nodither_table_8()
Pixel * pixel_table
Definition: getx11.h:179
static void MAG_2or3_nodither_table_8()
static void map_1_mono_color_8()
static void MAG_1_dither_table_8()
static void map_1_nodither_notable_32()
static void MAG_2or3_dither_table_8()
XImage * image
Definition: getx11.h:129
static void MAG_scanline_generic()
Boolean mono_img
Definition: getx11.h:164
static void MAG_1_mono_color_8()
int i
Definition: rletorla.c:82
char progname[30]
Definition: rletorla.c:79
VOID_FUNCTION * MAG_scanline
Definition: getx11.h:144
#define COUNT_OF(_array_)
Definition: getx11.h:50
Boolean dither_img
Definition: getx11.h:165
static void map_1_dither_table_8()
VOID_FUNCTION * map_scanline
Definition: getx11.h:143
static void map_scanline_generic()
static void MAG_1_nodither_notable_32()
void create_windows ( register image_information img,
char *  window_geometry 
)
void destroy_X_image ( image_information img,
XImage *  image 
)

Definition at line 238 of file x11_stuff.c.

241 {
242 #ifdef X_SHARED_MEMORY
243  if ( use_shared_pixmaps && image == img->image && img->shm_img.shmid >= 0 )
244  {
245  XShmDetach (dpy, &img->shm_img);
246  XDestroyImage (image);
247  shmdt( img->shm_img.shmaddr );
248  shmctl( img->shm_img.shmid, IPC_RMID, 0 );
249  img->shm_img.shmid = -1;
250  }
251  else
252 #endif
253  XDestroyImage( image );
254 
255  image = NULL;
256 }
Display * dpy
Definition: getx10.c:94
XShmSegmentInfo shm_img
Definition: getx11.h:183
Boolean use_shared_pixmaps
Definition: getx11.c:85
XImage * image
Definition: getx11.h:129
Colorindex * image
Definition: getmex.c:29
void determine_icon_size ( int  image_width,
int  image_height,
int icon_width,
int icon_height,
int icon_factor 
)

Definition at line 466 of file x11_stuff.c.

470 {
471  XIconSize *icon_sizes;
472  int icon_size_count;
473  int width, height, factor;
474  int i;
475 
476  /*
477  * We want the Icon to be about DESIRED_ICON_WIDTH x DESIRED_ICON_HEIGHT.
478  * First, make sure that is OK with the window manager.
479  * Then figure out the icon scaling factor.
480  */
481 
482 #define DESIRED_ICON_WIDTH 48
483 #define DESIRED_ICON_HEIGHT 48
484 
485  width = DESIRED_ICON_WIDTH;
486  height = DESIRED_ICON_HEIGHT;
487 
488  if (XGetIconSizes (dpy, root_window, &icon_sizes, &icon_size_count)
489  && icon_size_count >= 1) {
490 
491  for (i = 0; i < icon_size_count; i++) {
492  if (icon_sizes[i].min_width <= DESIRED_ICON_WIDTH
493  && icon_sizes[i].max_width >= DESIRED_ICON_WIDTH
494  && icon_sizes[i].min_height <= DESIRED_ICON_HEIGHT
495  && icon_sizes[i].max_height >= DESIRED_ICON_HEIGHT) {
496  break;
497  }
498  }
499 
500  if (i >= icon_size_count) {
501  width = icon_sizes[0].max_width;
502  height = icon_sizes[0].max_height;
503  }
504 
505  }
506 
507  factor = image_width / width;
508  if (factor < image_height / height)
509  factor = image_height / height;
510  if ( factor == 0 )
511  factor = 1;
512 
513  *icon_width = 1 + (image_width / factor);
514  *icon_height = 1 + (image_height / factor);
515  *icon_factor = factor;
516 }
Display * dpy
Definition: getx10.c:94
int width
Definition: pgmtorle.c:51
Window root_window
Definition: getx11.c:76
int height
Definition: pgmtorle.c:51
#define DESIRED_ICON_HEIGHT
int i
Definition: rletorla.c:82
#define DESIRED_ICON_WIDTH
void DrawPixWindow ( image_information img,
int  x,
int  y 
)

Definition at line 1997 of file x11_stuff.c.

2000 {
2001  char str[256];
2002  unsigned char *r, *g, *b;
2003 
2004  r = SAVED_RLE_ROW( img, y ) + x;
2005 
2006  switch ( img->dpy_channels ) {
2007  case 1:
2008  if ( img->mono_color && img->in_cmap ) {
2009  unsigned char R = img->in_cmap[0][*r];
2010  unsigned char G = img->in_cmap[1][*r];
2011  unsigned char B = img->in_cmap[2][*r];
2012  if ( img->mag_fact > 1 )
2013  sprintf (str, "(%4d,%4d): %3d -> 0x%02x%02x%02x ( %3d, %3d, %3d ) (Mag %2d)",
2014  x + img->x, img->h - y - 1 + img->y,
2015  *r, R, G, B, R, G, B, img->mag_fact);
2016  else
2017  sprintf (str, "(%4d,%4d): %3d -> 0x%02x%02x%02x ( %3d, %3d, %3d )",
2018  x + img->x, img->h - y - 1 + img->y,
2019  *r, R, G, B, R, G, B);
2020  } else {
2021  if ( img->mag_fact > 1 )
2022  sprintf (str, "(%4d,%4d): ( %3d ) (Mag %2d)",
2023  x + img->x, img->h - y - 1 + img->y,
2024  *r, img->mag_fact);
2025  else
2026  sprintf (str, "(%4d,%4d): ( %3d )",
2027  x + img->x, img->h - y - 1 + img->y, *r);
2028  }
2029  break;
2030  case 2:
2031  g = r + img->w;
2032  if ( img->mag_fact > 1 )
2033  sprintf (str, "(%4d,%4d): ( %3d, %3d ) (Mag %2d)",
2034  x + img->x, img->h - y - 1 + img->y,
2035  *r, *g, img->mag_fact);
2036  else
2037  sprintf (str, "(%4d,%4d): ( %3d, %3d )",
2038  x + img->x, img->h - y - 1 + img->y,
2039  *r, *g);
2040  break;
2041  case 3:
2042  g = r + img->w;
2043  b = g + img->w;
2044  if ( img->mag_fact > 1 )
2045  sprintf (str,
2046  "(%4d,%4d): 0x%02x%02x%02x ( %3d, %3d, %3d ) (Mag %2d)",
2047  x + img->x, img->h - y - 1 + img->y,
2048  *r, *g, *b, *r, *g, *b, img->mag_fact);
2049  else
2050  sprintf (str, "(%4d,%4d): 0x%02x%02x%02x ( %3d, %3d, %3d )",
2051  x + img->x, img->h - y - 1 + img->y,
2052  *r, *g, *b, *r, *g, *b);
2053  break;
2054  }
2055 
2056  XClearWindow ( dpy, img->pix_info_window );
2057  XDrawString ( dpy, img->pix_info_window, img->gc,
2058  4, 2 + pixel_font_info->ascent, str, strlen (str) );
2059 }
static unsigned char g
Definition: getami.c:692
static unsigned int R[32]
Definition: getami.c:98
Display * dpy
Definition: getx10.c:94
static unsigned char r
Definition: getami.c:692
static int y
Definition: getami.c:691
Boolean mono_color
Definition: getx11.h:168
static unsigned char b
Definition: getami.c:692
static unsigned int B[32]
Definition: getami.c:98
static int x
Definition: getami.c:691
#define SAVED_RLE_ROW(img, y)
Definition: getx11.h:192
static unsigned int G[32]
Definition: getami.c:98
static XFontStruct * pixel_font_info
Definition: x11_stuff.c:1959
rle_pixel ** in_cmap
Definition: getx11.h:171
Window pix_info_window
Definition: getx11.h:126
char * str
Definition: rletorla.c:79
void DrawSpeedWindow ( image_information img,
int  s 
)

Definition at line 2062 of file x11_stuff.c.

2065 {
2066  char str[256];
2067 
2068  if ( s > 0 )
2069  sprintf( str, "%s%d Frames/Second", (s > 0) ? "": "1/", (s>0)?s:-s );
2070  else
2071  sprintf( str, "As fast as possible" );
2072 
2073  XClearWindow ( dpy, img->pix_info_window );
2074  XDrawString ( dpy, img->pix_info_window, img->gc,
2075  4, 2 + pixel_font_info->ascent, str, strlen (str) );
2076 }
Display * dpy
Definition: getx10.c:94
_urt_stack * s
Definition: rleClock.c:919
static XFontStruct * pixel_font_info
Definition: x11_stuff.c:1959
Window pix_info_window
Definition: getx11.h:126
char * str
Definition: rletorla.c:79
int eq_cmap ( register rle_pixel **  cm1,
int  len1,
register rle_pixel **  cm2,
int  len2 
)
void find_appropriate_visual ( register image_information img)
void free_image_colors ( image_information img)

Definition at line 1679 of file x11_stuff.c.

1681 {
1682  int ncells = img->mono_img ? img->lvls : img->lvls*img->lvls*img->lvls;
1683  if ( img->rw_cmap && !img->binary_img )
1684  XFreeColors(dpy, img->colormap, img->pixel_table, ncells, 0);
1685 }
Display * dpy
Definition: getx10.c:94
Boolean rw_cmap
Definition: getx11.h:166
Pixel * pixel_table
Definition: getx11.h:179
Boolean binary_img
Definition: getx11.h:163
Boolean mono_img
Definition: getx11.h:164
Colormap colormap
Definition: getx11.h:130
void free_unique_colors ( image_information img,
Pixel pixels,
int  npixels 
)

Definition at line 1259 of file x11_stuff.c.

1263 {
1264  Pixel *p;
1265  int i, nunique;
1266 
1267  if ( no_color_ref_counts )
1268  {
1269  qsort(pixels, npixels, sizeof(Pixel), pixcompare);
1270  p = pixels;
1271 
1272  for (i=1; i<npixels; i++ ) {
1273  if ( pixels[i] != *p ) {
1274  p += 1;
1275  *p = pixels[i];
1276  }
1277  }
1278 
1279  nunique = (p - pixels) + 1;
1280 
1281  DPRINTF(stderr, "In free_unique_pixels \n\nPixels: ");
1282  for (i=0;i<nunique;i++) DPRINTF(stderr, " %d ",pixels[i]);
1283  DPRINTF(stderr, "\n");
1284  }
1285  else
1286  nunique = npixels;
1287 
1288  XFreeColors(dpy, img->colormap, pixels, nunique, 0);
1289 }
Display * dpy
Definition: getx10.c:94
Boolean no_color_ref_counts
Definition: getx11.c:88
static int pixcompare(Pixel *pixel1, Pixel *pixel2)
Definition: x11_stuff.c:1253
#define DPRINTF
Definition: getx11.h:62
int i
Definition: rletorla.c:82
Colormap colormap
Definition: getx11.h:130
unsigned long Pixel
Definition: getx11.h:54
void free_X_pixmap ( image_information img,
Pixmap  pix 
)

Definition at line 429 of file x11_stuff.c.

432 {
433  XFreePixmap( dpy, pix );
434 #ifdef X_SHARED_MEMORY
435  if ( use_shared_pixmaps && pix == img->pixmap && img->shm_pix.shmid >= 0 )
436  {
437  XShmDetach( dpy, &img->shm_pix );
438  shmdt( img->shm_pix.shmaddr );
439  shmctl( img->shm_pix.shmid, IPC_RMID, 0 );
440  img->shm_pix.shmid = -1;
441  }
442 #endif
443 }
Display * dpy
Definition: getx10.c:94
Boolean use_shared_pixmaps
Definition: getx11.c:85
XShmSegmentInfo shm_pix
Definition: getx11.h:184
void get_cursors ( Window  window)

Definition at line 84 of file x11_stuff.c.

86 {
87  if (circle_cursor == NULL)
88  circle_cursor = XCreateFontCursor (dpy, XC_circle);
89 
90  if (watch_cursor == NULL)
91  watch_cursor = XCreateFontCursor (dpy, XC_watch);
92 
93  if (left_ptr_cursor == NULL)
94  left_ptr_cursor = XCreateFontCursor (dpy, XC_left_ptr);
95 
96  if (circle_cursor == NULL) {
97  Pixmap source;
98  Pixmap mask;
99  XColor color_1;
100  XColor color_2;
101 
102  source = XCreateBitmapFromData(dpy, window, circle_bits,
103  circle_width, circle_height);
104 
105  mask = XCreateBitmapFromData(dpy, window, circle_mask_bits,
106  circle_width, circle_height);
107 
108  color_1.pixel = WhitePixel (dpy, screen);
109  color_1.red = 0xffff;
110  color_1.green = 0xffff;
111  color_1.blue = 0xffff;
112  color_1.flags = DoRed | DoGreen | DoBlue;
113 
114  color_1.pixel = BlackPixel (dpy, screen);
115  color_2.red = 0;
116  color_2.green = 0;
117  color_2.blue = 0;
118  color_2.flags = DoRed | DoGreen | DoBlue;
119 
120  circle_cursor = XCreatePixmapCursor (dpy, source, mask,
121  &color_1, &color_2,
122  circle_x_hot, circle_y_hot);
123  XFreePixmap (dpy, source);
124  XFreePixmap (dpy, mask);
125  }
126 
127  if (watch_cursor == NULL)
129 
130  if (left_ptr_cursor == NULL)
132 }
static unsigned mask
Definition: mcut.c:162
Display * dpy
Definition: getx10.c:94
static struct NewScreen screen
Definition: getami.c:67
static Cursor circle_cursor
Definition: x11_stuff.c:55
static struct NewWindow window
Definition: getami.c:80
static Cursor watch_cursor
Definition: x11_stuff.c:57
static Cursor left_ptr_cursor
Definition: x11_stuff.c:56
void get_dither_arrays ( register image_information img)
void get_dither_colors ( register image_information img,
rle_hdr img_hdr 
)
void get_x_colormap ( image_information img)

Definition at line 519 of file x11_stuff.c.

521 {
522  img->colormap = XCreateColormap (dpy, root_window,
523  img->dpy_visual, AllocNone );
524  if (img->colormap == NULL)
525  fprintf(stderr, "getx11: Could not create color map for visual\n");
526  else {
527  VPRINTF(stderr, "created colormap for visual type %s\n",
529  }
530 }
Display * dpy
Definition: getx10.c:94
Window root_window
Definition: getx11.c:76
Visual * dpy_visual
Definition: getx11.h:132
#define VPRINTF
Definition: aliastorle.c:42
static const char * visual_class_to_string()
Colormap colormap
Definition: getx11.h:130
XImage* get_X_image ( image_information img,
int  width,
int  height,
Boolean  share 
)

Definition at line 135 of file x11_stuff.c.

139 {
140  XImage *image;
141 #ifdef X_SHARED_MEMORY
142  int shmid = -1;
143 
144  if ( use_shared_pixmaps && share )
145  {
146  img->shm_img.shmid = -1;
147  image = XShmCreateImage( dpy, img->dpy_visual,
148  (img->binary_img ? 1 : img->dpy_depth),
149  (img->binary_img ? XYBitmap : ZPixmap),
150  NULL, &img->shm_img, width, height );
151  if ( image != NULL )
152  {
153  /* Allocate shared segment. */
154  img->shm_img.shmid =
155  shmget( IPC_PRIVATE,
156  image->bytes_per_line * image->height,
157  IPC_CREAT|0777 );
158  if ( img->shm_img.shmid < 0 )
159  {
160  if ( errno == ENOSPC )
161  {
162  if ( !no_shared_space )
163  fprintf( stderr,
164  "getx11: No more shared memory segments\n" );
165  no_shared_space = True;
166  }
167  else
168  perror( "getx11: shared memory allocation failed" );
169  XDestroyImage( image );
170  image = NULL;
171  }
172  else
173  {
174  /* Attach the segment & get its address. */
175  img->shm_img.shmaddr = image->data =
176  shmat( img->shm_img.shmid, 0, 0 );
177 
178  if ( image->data == NULL) {
179  perror ( "getx11: attach shared image->data" );
180  XDestroyImage (image);
181  shmctl( img->shm_img.shmid, IPC_RMID, 0 );
182  img->shm_img.shmid = -1;
183  image = NULL;
184  }
185  else
186  {
187  /* Want to write into the segment! */
188  img->shm_img.readOnly = False;
189 
190  /* Tell the X server about it. */
191  if ( !XShmAttach( dpy, &img->shm_img ) )
192  {
193  fprintf( stderr, "getx11: XShmAttach failed.\n" );
194  XDestroyImage (image);
195  shmdt( img->shm_img.shmaddr );
196  shmctl( img->shm_img.shmid, IPC_RMID, 0 );
197  img->shm_img.shmid = -1;
198  image = NULL;
199  }
200  }
201  }
202  }
203  shmid = img->shm_img.shmid;
204  }
205 
206  /* If not sharing, or if sharing failed, make a normal XImage. */
207  if ( shmid >= 0 )
208  {
209  /* Remove it now so it will go when we die.
210  * Another nice side effect: we don't fill up the SHM table,
211  * so we can allocate hundreds of them.
212  */
213  XSync( dpy, False ); /* Make sure the server knows about it. */
214  shmctl( shmid, IPC_RMID, 0 );
215  }
216  else
217 #endif
218  {
219  image = XCreateImage ( dpy, img->dpy_visual,
220  (img->binary_img ? 1 : img->dpy_depth),
221  (img->binary_img ? XYBitmap : ZPixmap),
222  0, NULL, width, height, 32, 0);
223 
224  if (image != NULL) {
225  image->data = (char *)malloc ( image->bytes_per_line * height );
226  if ( image->data == NULL) {
227  perror ( "malloc image->data" );
228  XDestroyImage (image);
229  image = NULL;
230  }
231  }
232  }
233  return (image);
234 
235 }
Display * dpy
Definition: getx10.c:94
XShmSegmentInfo shm_img
Definition: getx11.h:183
int width
Definition: pgmtorle.c:51
Boolean use_shared_pixmaps
Definition: getx11.c:85
int height
Definition: pgmtorle.c:51
Visual * dpy_visual
Definition: getx11.h:132
void_star shmat()
Boolean binary_img
Definition: getx11.h:163
Colorindex * image
Definition: getmex.c:29
void * malloc()
Boolean no_shared_space
Definition: getx11.c:86
void handle_exposure ( register image_information img,
int  x,
int  y,
int  width,
int  height,
int  img_h 
)
void init_color ( register image_information img)
void init_img_info ( image_information i)

Definition at line 107 of file getx11.c.

109 {
110  i->window = i->icn_window = NULL;
111  i->pixmap = i->icn_pixmap = NULL;
112  i->pix_info_window = NULL;
113  i->gc = i->icn_gc = NULL;
114  i->image = i->icn_image = NULL;
115  i->colormap = NULL;
116  i->visual_class = -1;
117  i->pixmap_failed = False;
118 
119  i->filename = NULL;
120  i->img_num = 0;
121  i->title = NULL;
122  i->fd = stdin;
123  i->img_channels = 0;
124  i->dpy_channels = 0;
125  i->scan_data = NULL;
126  i->map_scanline = NULL;
127  i->MAG_scanline = NULL;
128  i->gamma = 0.0;
129 
130  i->x = i->y = 0;
131  i->xo = i->yo = 0;
132  i->w = i->h = 0;
133  i->win_w = i->win_h = 0;
134  i->icn_w = i->icn_h = 0;
135  i->pix_w = i->pix_h = 0;
136  i->icn_factor = 1;
137 
138  i->pan_x = i->pan_x = 0;
139  i->pan_w = i->pan_h = 0;
140  i->mag_fact = 1;
141  i->save_mag_fact = 1;
142  i->mag_mode = False;
143 
144  i->binary_img = False;
145  i->dither_img = False;
146  i->mono_img = False;
147  i->rw_cmap = False;
148  i->sep_colors = False;
149  i->mono_color = False;
150  i->color_dpy = True;
151 
152  i->in_cmap = NULL;
153  i->ncmap = 0;
154  i->cmlen = 0;
155  i->modN = NULL;
156  i->divN = NULL;
157  i->dm16 = NULL;
158  i->pixel_table = NULL;
159  i->x_cmap.red_mask = i->x_cmap.green_mask = i->x_cmap.blue_mask = 1;
161  i->x_cmap.pixel_base = 0;
162  i->black_pixel = 0;
163  i->white_pixel = 1;
164 #ifdef X_SHARED_MEMORY
165  i->shm_img.shmid = -1;
166  i->shm_pix.shmid = -1;
167 #endif
168 }
unsigned char * scan_data
Definition: getx11.h:140
cmap_info x_cmap
Definition: getx11.h:178
Pixel blue_mask
Definition: getx11.h:119
Boolean rw_cmap
Definition: getx11.h:166
Pixel green_mask
Definition: getx11.h:118
Boolean pixmap_failed
Definition: getx11.h:134
Boolean mag_mode
Definition: getx11.h:158
XShmSegmentInfo shm_img
Definition: getx11.h:183
Pixel red_mask
Definition: getx11.h:117
const char * title
Definition: getx11.h:137
XShmSegmentInfo shm_pix
Definition: getx11.h:184
Pixel pixel_base
Definition: getx11.h:120
const char * filename
Definition: getx11.h:136
Boolean mono_color
Definition: getx11.h:168
Window icn_window
Definition: getx11.h:125
Pixel * pixel_table
Definition: getx11.h:179
Boolean color_dpy
Definition: getx11.h:169
Boolean binary_img
Definition: getx11.h:163
Boolean sep_colors
Definition: getx11.h:167
Pixmap icn_pixmap
Definition: getx11.h:127
XImage * image
Definition: getx11.h:129
XImage * icn_image
Definition: getx11.h:129
Boolean mono_img
Definition: getx11.h:164
rle_pixel ** in_cmap
Definition: getx11.h:171
Pixel black_pixel
Definition: getx11.h:180
VOID_FUNCTION * MAG_scanline
Definition: getx11.h:144
Window pix_info_window
Definition: getx11.h:126
Colormap colormap
Definition: getx11.h:130
Boolean dither_img
Definition: getx11.h:165
VOID_FUNCTION * map_scanline
Definition: getx11.h:143
array16 * dm16
Definition: getx11.h:177
Pixel white_pixel
Definition: getx11.h:180
void main ( int  argc,
char **  argv 
)

Definition at line 121 of file aliastorle.c.

124 {
125  char *inname = NULL;
126  char *outname = NULL;
127  FILE *infile;
128  FILE *outfile;
129  int oflag = 0;
131 
132  the_hdr = *rle_hdr_init( (rle_hdr *)NULL );
133  /*
134  * Get options
135  */
136  if ( !scanargs( argc, argv, "% v%- o%-outfile!s infile%s",
137  &verbose, &oflag, &outname, &inname ))
138  exit( 1 );
139 
140  /* An input file name ? */
141  rle_names( &the_hdr, cmd_name( argv ), inname, 0 );
142  infile= rle_open_f(the_hdr.cmd, inname, "r");
143 
144 
145  /*
146  * Translate Alias "pix" format into my bitmap.
147  */
148  read_alias(infile, &bitmap);
149  rle_close_f(infile); /* We finish with this file */
150 
151  /*
152  * We have a bitmap with the image, so we open the
153  * new rle file and write it.
154  */
155  outfile = rle_open_f(cmd_name(argv), outname, "w");
156  write_rle(outfile, &bitmap);
157  fclose(outfile); /* it is not necesary, but ... */
158 
159  exit(0);
160 }
rle_hdr the_hdr
Definition: aliastorle.c:100
int scanargs(int argc, char **argv, const char *format,...)
Definition: scanargs.c:94
FILE * outfile
Definition: giftorle.c:61
static int read_alias(FILE *, bitmap_hdr *)
Definition: aliastorle.c:163
static void write_rle(FILE *, bitmap_hdr *)
Definition: aliastorle.c:473
int verbose
Definition: aliastorle.c:96
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
const char * cmd
Definition: rle.h:133
Definition: rle.h:96
void rle_close_f(FILE *fd)
Definition: rle_open_f.c:244
FILE * infile
Definition: targatorle.c:102
gpr_ $bitmap_desc_t bitmap
Definition: getap.c:110
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
char * cmd_name(char **argv)
Definition: cmd_name.c:31
int oflag
Definition: painttorle.c:45
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
Definition: rle_hdr.c:267
void map_rgb_to_bw ( image_information img,
rle_pixel **  rows,
register rle_pixel bw_row 
)
void map_rgb_to_rgb ( image_information img,
rle_pixel **  in_rows,
rle_pixel **  out_rows 
)

Definition at line 2139 of file map_scan.c.

2142 {
2143  register rle_pixel *in, *out, *cmap;
2144  register int w;
2145  rle_pixel **map;
2146  int ncolors;
2147  int rowlen;
2148 
2149  map = img->in_cmap;
2150  ncolors = img->img_channels;
2151  rowlen = img->w;
2152 
2153  if ( ncolors < 1 )
2154  {
2155  fprintf (stderr, "%s: map_rgb_to_rgb given %d colors\n",
2156  progname, ncolors);
2157  exit (1);
2158  }
2159 
2160  if ( map )
2161  while ( --ncolors >= 0 )
2162  {
2163  in = in_rows[0];
2164  out = out_rows[0];
2165  cmap = map[0];
2166  w = rowlen;
2167 
2168  duff8( w, *out++ = cmap[*in++] );
2169 
2170  in_rows++;
2171  out_rows++;
2172  map++;
2173  }
2174  else
2175  while ( --ncolors >= 0 )
2176  {
2177  if ( in_rows[0] != out_rows[0] )
2178  memcpy( out_rows[0], in_rows[0], rowlen );
2179 
2180  in_rows++;
2181  out_rows++;
2182  }
2183 }
rle_pixel ** in_rows
Definition: unexp.c:20
short map[3][256]
Definition: getap.c:115
#define duff8(counter, block)
Definition: getx11.h:196
rle_pixel ** out_rows
Definition: unexp.c:21
unsigned char rle_pixel
Definition: rle.h:56
rle_pixel ** in_cmap
Definition: getx11.h:171
char progname[30]
Definition: rletorla.c:79
rle_pixel ** cmap
Definition: get4d.c:47
void MapPixWindow ( image_information img,
int  use_top 
)

Definition at line 1962 of file x11_stuff.c.

1965 {
1966  Window hukairz;
1967  int x, y;
1968  unsigned int w, h, hunoz, huwanz, font_height;
1969 
1970  XGetGeometry (dpy, img->window, &hukairz, &x, &y, &w, &h, &hunoz, &huwanz);
1971 
1972  if (!pixel_font_info) {
1973  pixel_font_info = XLoadQueryFont (dpy, "fixed");
1974  if (!pixel_font_info) {
1975  fprintf (stderr, "%s: unable to load font '%s'\n",
1976  progname, "fixed");
1977  exit (1);
1978  }
1979  }
1980 
1981  font_height = pixel_font_info->ascent + pixel_font_info->descent + 4;
1982  y = (use_top ? 0 : (h - font_height));
1983 
1984  if ( img->pix_info_window == NULL ) {
1985  XSetFont (dpy, img->gc, pixel_font_info->fid );
1986  img->pix_info_window = XCreateSimpleWindow(
1987  dpy, img->window, 0, y, w, font_height, 0, None,
1988  img->black_pixel );
1989  }
1990  else
1991  XMoveResizeWindow ( dpy, img->pix_info_window, 0, y, w, font_height );
1992 
1993  XMapWindow ( dpy, img->pix_info_window );
1994 }
Display * dpy
Definition: getx10.c:94
static int y
Definition: getami.c:691
static int x
Definition: getami.c:691
static XFontStruct * pixel_font_info
Definition: x11_stuff.c:1959
char progname[30]
Definition: rletorla.c:79
Pixel black_pixel
Definition: getx11.h:180
Window pix_info_window
Definition: getx11.h:126
void open_x_display ( char *  display_name)

Definition at line 532 of file x11_stuff.c.

534 {
535  /* Check to see if user explicitly specified the screen with -d. */
536  if ( display_name )
537  {
538  char *dotp = strrchr( display_name, '.' );
539  char *colonp = strrchr( display_name, ':' );
540 
541  /* If the dot follows the colon, then it's a screen designator. */
542  if ( dotp && colonp && dotp > colonp && dotp[1] != '\0' )
543  specified_screen = atoi( dotp+1 );
544  }
545 
546  if (display_name == NULL || *display_name == '\0')
547  display_name = getenv("DISPLAY");
548 
549  dpy = XOpenDisplay(display_name);
550 
551  if (dpy == NULL) {
552  fprintf(stderr, "%s: Cant open display %s\n", progname,
553  (display_name == NULL) ? "" : display_name);
554  exit(1);
555  }
556 
557 #ifdef X_SHARED_MEMORY
558  if (do_sharing)
559  {
560  Status sh_status;
561  int sh_major, sh_minor;
562  Boolean sh_pixmaps = False;
563 
564  sh_status = XShmQueryVersion( dpy, &sh_major, &sh_minor, &sh_pixmaps );
565  use_shared_pixmaps = (Boolean)(sh_status && sh_pixmaps);
566  }
567 #endif
568  /* Work around bug in X11/NeWS server colormap allocation. */
569  if (strcmp("X11/NeWS - Sun Microsystems Inc.", ServerVendor(dpy)) == 0 &&
570  VendorRelease(dpy) == 2000)
571  no_color_ref_counts = True;
572 
573 }
int Boolean
Definition: getx11.h:53
Display * dpy
Definition: getx10.c:94
Boolean do_sharing
Definition: getx11.c:84
Boolean use_shared_pixmaps
Definition: getx11.c:85
Boolean no_color_ref_counts
Definition: getx11.c:88
static int specified_screen
Definition: x11_stuff.c:59
string display_name
Definition: getbob.c:80
char progname[30]
Definition: rletorla.c:79
void put_X_image ( image_information img,
Drawable  d,
GC  gc,
XImage *  image,
int  src_x,
int  src_y,
int  dest_x,
int  dest_y,
unsigned int  width,
unsigned int  height 
)

Definition at line 446 of file x11_stuff.c.

454 {
455 #ifdef X_SHARED_MEMORY
456  if ( use_shared_pixmaps && img->image == image && img->shm_img.shmid >= 0 )
457  XShmPutImage( dpy, d, gc, image, src_x, src_y, dest_x, dest_y,
458  width, height, False );
459  else
460 #endif
461  XPutImage( dpy, d, gc, image, src_x, src_y, dest_x, dest_y,
462  width, height );
463 }
Display * dpy
Definition: getx10.c:94
XShmSegmentInfo shm_img
Definition: getx11.h:183
int width
Definition: pgmtorle.c:51
Boolean use_shared_pixmaps
Definition: getx11.c:85
int height
Definition: pgmtorle.c:51
XImage * image
Definition: getx11.h:129
Colorindex * image
Definition: getmex.c:29
int resize_window ( image_information img,
int  new_w,
int  new_h 
)

Definition at line 1424 of file getx11.c.

1427 {
1428  int old_w = img->win_w;
1429  int old_h = img->win_h;
1430  int iw = img->w * img->mag_fact;
1431  int ih = img->h * img->mag_fact;
1432  int retval = 0;
1433 
1434  img->win_w = new_w;
1435  img->win_h = new_h;
1436  calc_view_origin( img );
1437 
1438  if ( old_w < iw || new_w < iw || old_h < ih || new_h < ih ) {
1439  allocate_ximage( img, True );
1440  if (img->pixmap)
1441  allocate_pixmap( img, True );
1442  retval = 1;
1443  }
1444 
1445  return retval;
1446 }
void calc_view_origin(image_information *img)
Definition: x11_stuff.c:575
int allocate_ximage(image_information *img, Boolean reallocate)
Definition: x11_stuff.c:301
void allocate_pixmap(image_information *img, Boolean reallocate)
Definition: x11_stuff.c:325
void set_circle_cursor ( Window  window)

Definition at line 70 of file x11_stuff.c.

72 {
73  XDefineCursor( dpy, window, circle_cursor );
74  XFlush(dpy);
75 }
Display * dpy
Definition: getx10.c:94
static Cursor circle_cursor
Definition: x11_stuff.c:55
static struct NewWindow window
Definition: getami.c:80
void set_left_ptr_cursor ( Window  window)

Definition at line 77 of file x11_stuff.c.

79 {
80  XDefineCursor( dpy, window, left_ptr_cursor );
81  XFlush(dpy);
82 }
Display * dpy
Definition: getx10.c:94
static struct NewWindow window
Definition: getami.c:80
static Cursor left_ptr_cursor
Definition: x11_stuff.c:56
void set_timer ( unsigned  n)

Definition at line 46 of file timer.c.

48 {
49 #ifndef NO_ITIMER
50  struct itimerval itv;
51  register struct itimerval *itp = &itv;
52  if (n == 0)
53  {
54  ringring = 1;
55  return;
56  }
57  timerclear(&itp->it_interval);
58  itp->it_value.tv_sec = n / USPS;
59  itp->it_value.tv_usec = n % USPS;
60  ofunc = (void (*)())signal(SIGALRM, sleepx);
61 
62  ringring = 0;
63  (void) setitimer(ITIMER_REAL, itp, (struct itimerval *)0);
64 #endif
65 }
static void(* ofunc)()
Definition: timer.c:36
#define USPS
Definition: timer.c:31
static int ringring
Definition: timer.c:35
static void sleepx()
Definition: timer.c:39
void set_watch_cursor ( Window  window)

Definition at line 63 of file x11_stuff.c.

65 {
66  XDefineCursor( dpy, window, watch_cursor );
67  XFlush(dpy);
68 }
Display * dpy
Definition: getx10.c:94
static struct NewWindow window
Definition: getami.c:80
static Cursor watch_cursor
Definition: x11_stuff.c:57
int shift_match_left ( Pixel  mask,
int  high_bit_index 
)

Definition at line 2205 of file map_scan.c.

2210 {
2211  register int shift;
2212  register Pixel high_bit;
2213 
2214  if (mask == 0) return (0);
2215 
2216  high_bit = 0x80000000;
2217 
2218  for (shift = (32 - high_bit_index); (high_bit & mask) == 0; shift--) {
2219  high_bit >>= 1;
2220  }
2221  return (shift);
2222 }
static unsigned mask
Definition: mcut.c:162
unsigned long Pixel
Definition: getx11.h:54
int shift_match_right ( Pixel  mask)

Definition at line 2227 of file map_scan.c.

2229 {
2230  register int shift;
2231  register Pixel low_bit;
2232 
2233  if (mask == 0) return (0);
2234 
2235  low_bit = 1;
2236 
2237  for (shift = 0; (low_bit & mask) == 0; shift++) {
2238  low_bit <<= 1;
2239  }
2240  return (shift);
2241 }
static unsigned mask
Definition: mcut.c:162
unsigned long Pixel
Definition: getx11.h:54
void UnmapPixWindow ( image_information img)

Definition at line 2080 of file x11_stuff.c.

2082 {
2083  XUnmapWindow ( dpy, img->pix_info_window );
2084 }
Display * dpy
Definition: getx10.c:94
Window pix_info_window
Definition: getx11.h:126
void wait_timer ( void  )

Definition at line 72 of file timer.c.

73 {
74 #ifndef NO_ITIMER
75  while (!ringring)
76  sigpause( ~sigmask(SIGALRM));
77  signal(SIGALRM, ofunc);
78 #endif
79 }
static void(* ofunc)()
Definition: timer.c:36
static int ringring
Definition: timer.c:35
int XAllocColors ( register Display *  dpy,
Colormap  cmap,
XColor *  defs,
int  ndefs,
int statuses 
)
int XCopyImage ( XImage *  image,
int  src_x,
int  src_y,
int  width,
int  height,
int  dst_x,
int  dst_y 
)

Definition at line 35 of file XCopyImg.c.

38 {
39  int line_width = image->bytes_per_line;
40 
41  if ( width == 0 )
42  return False;
43 
44  switch ( image->bits_per_pixel )
45  {
46  case 1:
47  return False;
48 
49  case 8:
50  do {
51  char *srcline, *dstline;
52  register char *src, *dst;
53  register int counter;
54 
55  if ( src_y < dst_y )
56  {
57  srcline = image->data + line_width * (src_y+height-1) +
58  src_x;
59  dstline = image->data + line_width * (dst_y+height-1) +
60  dst_x;
61 
62  if ( src_x < dst_x ) {
63  dstline += width - 1;
64  while ( --height >= 0 ) {
65  src = srcline + width - 1;
66  dst = dstline;
67  counter = width;
68 
69  duff8( counter, *dst-- = *src-- );
70 
71  srcline -= line_width;
72  dstline -= line_width;
73  }
74  }
75  else {
76  srcline += width - 1;
77  while ( --height >= 0 ) {
78  src = srcline - width + 1;
79  dst = dstline;
80  counter = width;
81 
82  duff8( counter, *dst++ = *src++ );
83 
84  srcline -= line_width;
85  dstline -= line_width;
86  }
87  }
88  }
89  else
90  {
91  srcline = image->data + line_width * src_y + src_x;
92  dstline = image->data + line_width * dst_y + dst_x;
93 
94  if ( src_x < dst_x ) {
95 
96  dstline += width - 1;
97  while ( --height >= 0 ) {
98  src = srcline + width - 1;
99  dst = dstline;
100  counter = width;
101 
102  duff8( counter, *dst-- = *src-- );
103 
104  srcline += line_width;
105  dstline += line_width;
106  }
107  }
108  else {
109  srcline += width - 1;
110  while ( --height >= 0 ) {
111  src = srcline - width + 1;
112  dst = dstline;
113  counter = width;
114 
115  duff8( counter, *dst++ = *src++ );
116 
117  srcline += line_width;
118  dstline += line_width;
119  }
120  }
121  }
122  } while (0);
123  return True;
124 
125  case 32:
126  do {
127  register long *srcline, *dstline;
128  register long *src, *dst;
129 
130  if ( src_y < dst_y )
131  {
132  srcline = (long *) ((char *)image->data +
133  line_width * (src_y+height-1) +
134  src_x * sizeof(long));
135  dstline = (long *) ((char *)image->data +
136  line_width * (dst_y+height-1) +
137  dst_x * sizeof(long));
138 
139  if ( src_x < dst_x ) {
140 
141  dstline += width - 1;
142  while ( --height >= 0 ) {
143  src = srcline + width - 1;
144  dst = dstline;
145 
146  while ( src >= srcline )
147  *dst-- = *src--;
148 
149  srcline -= line_width/sizeof(long);
150  dstline -= line_width/sizeof(long);
151  }
152  }
153  else {
154  srcline += width - 1;
155  while ( --height >= 0 ) {
156  src = srcline - width + 1;
157  dst = dstline;
158 
159  while ( src <= srcline )
160  *dst++ = *src++;
161 
162  srcline -= line_width/sizeof(long);
163  dstline -= line_width/sizeof(long);
164  }
165  }
166  }
167  else
168  {
169  srcline = (long *) ((char *)image->data + line_width * src_y +
170  src_x * sizeof(long));
171  dstline = (long *) ((char *)image->data + line_width * dst_y +
172  dst_x * sizeof(long));
173 
174  if ( src_x < dst_x ) {
175 
176  dstline += width - 1;
177  while ( --height >= 0 ) {
178  src = srcline + width - 1;
179  dst = dstline;
180 
181  while ( src >= srcline )
182  *dst-- = *src--;
183 
184  srcline += line_width/sizeof(long);
185  dstline += line_width/sizeof(long);
186  }
187  }
188  else {
189  srcline += width - 1;
190  while ( --height >= 0 ) {
191  src = srcline - width + 1;
192  dst = dstline;
193 
194  while ( src <= srcline )
195  *dst++ = *src++;
196 
197  srcline += line_width/sizeof(long);
198  dstline += line_width/sizeof(long);
199  }
200  }
201  }
202  } while (0);
203  return True;
204  }
205  return False;
206 }
int width
Definition: pgmtorle.c:51
int height
Definition: pgmtorle.c:51
static int counter
Definition: XGetHClrs.c:12
#define duff8(counter, block)
Definition: getx11.h:196
Colorindex * image
Definition: getmex.c:29