void gks_drv_mac( int fctid, int dx, int dy, int dimx, int *ia, int lr1, double *r1, int lr2, double *r2, int lc, char *chars, void **ptr) { p = (ws_state_list *) *ptr; switch (fctid) { /* open workstation */ case 2: gkss = (gks_state_list_t *) *ptr; p = (ws_state_list *) calloc(1, sizeof(ws_state_list)); if (pthread_mutex_init(&p->mutex, NULL)) { perror("pthread_mutex_init"); exit(-1); } p->run = 0; if (pthread_create(&p->thread, NULL, exec, (void *) p)) { perror("pthread_create"); exit(-1); } while (!p->run) usleep(10000); p->port = GetWindowPort(p->win); SetPort(p->port); *ptr = p; break; /* close workstation */ case 3: p->run = 0; pthread_join(p->thread, NULL); pthread_mutex_destroy(&p->mutex); free(p); break; /* activate workstation */ case 4: p->state = GKS_K_WS_ACTIVE; break; /* deactivate workstation */ case 5: p->state = GKS_K_WS_INACTIVE; break; /* clear workstation */ case 6: clear_ws(); break; /* update workstation */ case 8: pthread_mutex_lock(&p->mutex); QDFlushPortBuffer(p->port, NULL); pthread_mutex_unlock(&p->mutex); break; /* polyline */ case 12: if (p->state == GKS_K_WS_ACTIVE) { pthread_mutex_lock(&p->mutex); LockPortBits(p->port); polyline(ia[0], r1, r2); UnlockPortBits(p->port); pthread_mutex_unlock(&p->mutex); } break; /* polymarker */ case 13: if (p->state == GKS_K_WS_ACTIVE) { pthread_mutex_lock(&p->mutex); LockPortBits(p->port); polymarker(ia[0], r1, r2); UnlockPortBits(p->port); pthread_mutex_unlock(&p->mutex); } break; /* text */ case 14: if (p->state == GKS_K_WS_ACTIVE) { pthread_mutex_lock(&p->mutex); LockPortBits(p->port); text(r1[0], r2[0], strlen(chars), chars); UnlockPortBits(p->port); pthread_mutex_unlock(&p->mutex); } break; /* fill area */ case 15: if (p->state == GKS_K_WS_ACTIVE) { pthread_mutex_lock(&p->mutex); LockPortBits(p->port); fillarea(ia[0], r1, r2); UnlockPortBits(p->port); pthread_mutex_unlock(&p->mutex); } break; /* cell array */ case 16: case DRAW_IMAGE: if (p->state == GKS_K_WS_ACTIVE) { int true_color = fctid == DRAW_IMAGE; pthread_mutex_lock(&p->mutex); LockPortBits(p->port); cellarray(r1[0], r1[1], r2[0], r2[1], dx, dy, dimx, ia, true_color); UnlockPortBits(p->port); pthread_mutex_unlock(&p->mutex); } break; /* set color representation */ case 48: set_color_rep(ia[1], r1[0], r1[1], r1[2]); break; case 49: /* set window */ set_norm_xform(*ia, gkss->window[*ia], gkss->viewport[*ia]); break; case 50: /* set viewport */ set_norm_xform(*ia, gkss->window[*ia], gkss->viewport[*ia]); if (*ia == gkss->cntnr) set_clip_rect(*ia); break; case 52: /* select normalization transformation */ case 53: /* set clipping inidicator */ set_clip_rect(gkss->cntnr); break; /* set workstation window */ case 54: p->window[0] = r1[0]; p->window[1] = r1[1]; p->window[2] = r2[0]; p->window[3] = r2[1]; set_xform(); init_norm_xform(); break; /* set workstation viewport */ case 55: p->viewport[0] = r1[0]; p->viewport[1] = r1[1]; p->viewport[2] = r2[0]; p->viewport[3] = r2[1]; if (p->state == GKS_K_WS_ACTIVE) { pthread_mutex_lock(&p->mutex); LockPortBits(p->port); resize_window(); set_xform(); init_norm_xform(); UnlockPortBits(p->port); pthread_mutex_unlock(&p->mutex); } break; /* request locator */ case 81: if (p->state == GKS_K_WS_ACTIVE) { pthread_mutex_lock(&p->mutex); QDFlushPortBuffer(p->port, NULL); get_pointer(r1, r2, &ia[0]); pthread_mutex_unlock(&p->mutex); } break; default: ; } }
/** Here we process the command line options */ void process_commandline(int argc, char *argv[], struct area_s *inarea, int *darker, int *copy_pixel, struct color_yuv *coloryuv, int *average_pixel) { int c; char area [20]; while ((c = getopt(argc, argv, "Hhv:i:s:d:c:a:")) != -1) { switch (c) { case 'v': verbose = atoi(optarg); if ( verbose < 0 || verbose > 2) print_usage(argv[0]); if (verbose == 2) mjpeg_info("Set Verbose = %i", verbose); break; case 'i': strncpy(area, optarg, 20); /* This part shows how to process */ fillarea(area, inarea); /* command line options */ break; case 's': strncpy(area, optarg, 20); set_yuvcolor(area, coloryuv); break; case 'd': *darker = atoi(optarg); break; case 'c': *copy_pixel = atoi(optarg); break; case 'a': *average_pixel = atoi(optarg); break; case 'H': case 'h': print_usage(argv[0]); } } /* Checking if we have used the -i option */ if ( ((*inarea).height == 0) && ((*inarea).width == 0) ) mjpeg_error_exit1("You have to use the -i option"); /* Checking the range of the darker -d option */ if ( (*darker < 0) || (*darker > 100) ) mjpeg_error_exit1("You can only make the area 1-100 percent darker"); else mjpeg_info("Setting the area %i percent darker", *darker); /* Checking the copy pixel option */ if (*copy_pixel != 0) { if ( ((*inarea).height/2) < *copy_pixel) { mjpeg_error("You can only copy half of the height into the area"); mjpeg_error_exit1("lower the copy pixel value below: %i ", ((*inarea).height/2)); } if ( (*copy_pixel % 2) != 0) mjpeg_error_exit1("you have to use a even number of lines to copy into the field"); if ( ((*inarea).height % *copy_pixel) != 0) mjpeg_error_exit1("the height has to be a multiply of the copy pixel value"); mjpeg_info("Number of rows using for coping into the area %i", *copy_pixel); } /* Checking the average pixel option */ if (*average_pixel != 0) { if ( (*average_pixel > (*inarea).height) || (*average_pixel > (*inarea).width) ) mjpeg_error_exit1("The pixles used for the average must be less the the inactive area"); if ( (*average_pixel % 2) != 0) mjpeg_error_exit1("you have to use a even number for the average pixels"); mjpeg_info("Number of pixels used for averaging %i", *average_pixel); } }