void CObjectGroup::Draw() { GR_IMAGE_INFO img_info; RECT rcOptionText; if(m_wid && m_gc && m_Image) { if(m_isOption) { GrGetImageInfo(m_Image[m_idxImage], &img_info); GrDrawImageToFit(m_wid, m_gc, m_rect.x, m_rect.y, img_info.width, img_info.height, m_Image[m_idxImage]); if(m_pszText) { memcpy(&rcOptionText, &m_rect, sizeof(RECT)); rcOptionText.x += (img_info.width + 10); DrawTextRect(m_pszText, m_wid, m_gc, &rcOptionText, m_text_font, m_text_size, m_text_color, m_text_align); } } else { GrDrawImageToFit(m_wid, m_gc, m_rect.x, m_rect.y, m_rect.w, m_rect.h, m_Image[m_idxImage]); if(m_pszText) { DrawTextRect(m_pszText, m_wid, m_gc, &m_rect, m_text_font, m_text_size, m_text_color, m_text_align); } } } }
static void GrGetImageInfoWrapper(void *r) { nxGetImageInfoReq *req = r; GR_IMAGE_INFO info; GrGetImageInfo(req->id, &info); GsWriteType(current_fd, GrNumGetImageInfo); GsWrite(current_fd, &info, sizeof(info)); }
/** * Load image from filename and return its ID */ GR_WINDOW_ID theme_load_image(char * filename) { GR_GC_ID gc; GR_IMAGE_ID iid; GR_WINDOW_ID pid; GR_IMAGE_INFO iif; gc = GrNewGC(); if(!(iid = GrLoadImageFromFile(filename, 0))) { fprintf(stderr, "Failed to load image file \"%s\"\n", filename); return 0; } GrGetImageInfo(iid, &iif); pid = GrNewPixmap(iif.width, iif.height, NULL); GrDrawImageToFit(pid, gc, 0, 0, iif.width, iif.height, iid); GrDestroyGC(gc); GrFreeImage(iid); return pid; }
void show_jpeg(int client, char *file, int show_time) { GR_EVENT event; /* current event */ GR_IMAGE_ID id = 0; GR_SIZE w = -1; GR_SIZE h = -1; GR_IMAGE_INFO info; GR_WINDOW_ID w1; /* id for large window */ GR_GC_ID gc1; /* graphics context for text */ GR_SCREEN_INFO si; int time_left; bool ever_exposed = false; #if !defined(HAVE_JPEG_SUPPORT) && !defined(HAVE_BMP_SUPPORT) && !defined(HAVE_GIF_SUPPORT) printf("Sorry, no image support compiled in\n"); exit(1); #endif GrGetScreenInfo(&si); printf("Loading image: %s\n", file); if (access(file, F_OK) < 0) { fdprintf(client, "Can't access \"%s\": %s\n", file, strerror(errno)); return; } id = GrLoadImageFromFile(file, 0); if (id) { GrGetImageInfo(id, &info); } else { // File exists, so why the error? int fd, len; char buf[64]; fdprintf(client, "Can't load %s\n", file); if ((fd = open(file, O_RDONLY)) >= 0) { len = read(fd, buf, 64); if (len != 64) { diag_printf("Short read? len = %d\n", len); } else { diag_dump_buf(buf, len); } close(fd); } else { diag_printf("Can't oopen \"%s\": %s\n", file, strerror(errno)); } return; } w = info.width; h = info.height; if ((si.rows < info.height) || (si.cols < info.width)) { // Preserve aspect ratio if (si.cols < info.width) { w = si.cols; h = (si.cols * info.height) / info.width; } if (si.rows < h) { w = (si.rows * w) / h; h = si.rows; } } printf("Create window - orig %dx%d => %dx%d\n", info.width, info.height, w, h); fdprintf(client, "<INFO> Display \"%s\" - orig %dx%d => %dx%d\n", file, info.width, info.height, w, h); w1 = GrNewWindow(GR_ROOT_WINDOW_ID, 10, 10, w, h, 4, BLACK, WHITE); GrSelectEvents(w1, GR_EVENT_MASK_CLOSE_REQ|GR_EVENT_MASK_EXPOSURE); GrMapWindow(w1); gc1 = GrNewGC(); GrSetGCForeground(gc1, WHITE); #define TO_MS 50 time_left = show_time * 1000; while (time_left > 0) { GrGetNextEventTimeout(&event, TO_MS); // milliseconds switch(event.type) { case GR_EVENT_TYPE_CLOSE_REQ: GrDestroyWindow(w1); GrFreeImage(id); return; /* no return*/ case GR_EVENT_TYPE_EXPOSURE: /*GrDrawImageFromFile(w1, gc1, 0, 0, w, h, argv[1],0);*/ GrDrawImageToFit(w1, gc1, 0, 0, w, h, id); ever_exposed = true; break; default: case GR_EVENT_TYPE_NONE: case GR_EVENT_TYPE_TIMEOUT: time_left -= TO_MS; if ((time_left < 0) && !ever_exposed) { // Things get real cranky if we delete the window too fast! time_left = TO_MS; } break; } } GrUnmapWindow(w1); GrDestroyWindow(w1); GrDestroyGC(gc1); GrFreeImage(id); }
void initialise(lstate *state) { GR_SCREEN_INFO si; GR_IMAGE_ID back_image; GR_IMAGE_INFO imageinfo; int rows = 1, columns = 1, width, height, x = 0, y = 0; GR_WM_PROPERTIES props; litem *i; if(GrOpen() < 0) { GrError("Couldn't connect to Nano-X server\n"); exit(4); } state->window_background_mode = 0; state->window_background_image = NULL; sspid = -1; read_config(state); GrGetScreenInfo(&si); if(si.rows > si.cols) { rows = state->numlitems; while((((rows / columns) + rows % columns) * ITEM_HEIGHT) > si.rows) { columns++; } if((columns * ITEM_WIDTH) > si.cols) goto toomany; rows = (rows / columns) + (rows % columns); width = columns * ITEM_WIDTH + 1 + columns; height = rows * ITEM_HEIGHT + 1 + rows; } else { columns = state->numlitems; while((((columns / rows) + (columns % rows)) * ITEM_WIDTH) > si.cols) { rows++; } if((rows * ITEM_HEIGHT) > si.rows) goto toomany; columns = (columns / rows) + (columns % rows); width = columns * ITEM_WIDTH + 1 + columns; height = (rows * ITEM_HEIGHT) + 1 + rows; y = si.rows - (rows * ITEM_HEIGHT) - 1 - rows; } state->gc = GrNewGC(); GrSetGCForeground(state->gc, ITEM_TEXT_COLOUR); GrSetGCBackground(state->gc, ITEM_BACKGROUND_COLOUR); if(state->window_background_image) { if(!(back_image = GrLoadImageFromFile( state->window_background_image, 0))) { GrError("Couldn't load background image\n"); } else { GrGetImageInfo(back_image, &imageinfo); if(!(state->background_pixmap = GrNewPixmap( imageinfo.width, imageinfo.height, NULL))) { GrError("Couldn't allocate pixmap " "for background image\n"); } else { GrDrawImageToFit(state->background_pixmap, state->gc, 0, 0, imageinfo.width, imageinfo.height, back_image); GrFreeImage(back_image); GrSetBackgroundPixmap(GR_ROOT_WINDOW_ID, state->background_pixmap, state->window_background_mode); GrClearWindow(GR_ROOT_WINDOW_ID, GR_TRUE); } } } if(state->ssitems) GrSelectEvents(GR_ROOT_WINDOW_ID, GR_EVENT_MASK_SCREENSAVER); state->main_window = GrNewWindow(GR_ROOT_WINDOW_ID, 0, y, width, height, 0, ITEM_BACKGROUND_COLOUR, 0); GrSelectEvents(state->main_window, GR_EVENT_MASK_CLOSE_REQ | GR_EVENT_MASK_TIMER); props.flags = GR_WM_FLAGS_PROPS; props.props = GR_WM_PROPS_NOMOVE | GR_WM_PROPS_NODECORATE | GR_WM_PROPS_NOAUTOMOVE | GR_WM_PROPS_NOAUTORESIZE; GrSetWMProperties(state->main_window, &props); i = state->lastlitem; y = 0; while(i) { i->wid = GrNewWindow(state->main_window, (x * ITEM_WIDTH) + x + 1, (y * ITEM_HEIGHT) + y + 1, ITEM_WIDTH, ITEM_HEIGHT, 1, ITEM_BACKGROUND_COLOUR, ITEM_BORDER_COLOUR); GrSelectEvents(i->wid, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_BUTTON_DOWN); GrMapWindow(i->wid); i = i->prev; if(++x == columns) { x = 0; y++; } } GrMapWindow(state->main_window); signal(SIGCHLD, &reaper); do_startups(state); return; toomany: GrError("Too many items to fit on screen\n"); exit(6); }
void parse_config_line(lstate *state, char *buf, int lineno) { char *p, *pp, *name, *icon; int n; litem *new_litem, *li; ssitem *new_ssitem, *tmp_ssitem; stitem *new_stitem, *tmp_stitem; GR_IMAGE_INFO imageinfo; p = buf; if((!*p) || (*p == '#') || (*p == '\n')) return; while(isspace(*p)) p++; name = p; while(*p && (!isspace(*p))) p++; if(!*p) goto premature; *p++ = 0; if(!strcmp(name, "$screensaver")) { new_ssitem = my_malloc(sizeof(ssitem)); if(!(new_ssitem->prog = make_prog_item(p, lineno))) { free(new_ssitem); return; } state->numssitems++; new_ssitem->next = NULL; if(!state->ssitems) state->ssitems = new_ssitem; else { tmp_ssitem = state->ssitems; while(tmp_ssitem->next) tmp_ssitem = tmp_ssitem->next; tmp_ssitem->next = new_ssitem; } return; } else if(!strcmp(name, "$startup")) { new_stitem = my_malloc(sizeof(stitem)); if(!(new_stitem->prog = make_prog_item(p, lineno))) { free(new_stitem); return; } new_stitem->next = NULL; if(!state->stitems) state->stitems = new_stitem; else { tmp_stitem = state->stitems; while(tmp_stitem->next) tmp_stitem = tmp_stitem->next; tmp_stitem->next = new_stitem; } return; } else if(!strcmp(name, "$screensaver_timeout")) { n = strtol(p, NULL, 10); GrSetScreenSaverTimeout(n); return; } else if(!strcmp(name, "$screensaver_rotate_time")) { state->rotatess = strtol(p, NULL, 10); return; } else if(!strcmp(name, "$random_screensaver")) { srand(time(0)); state->randomss = 1; return; } else if(!strcmp(name, "$window_background_image")) { while(isspace(*p)) p++; if(!*p) goto premature; pp = p; while(*p && (!isspace(*p))) p++; *p = 0; state->window_background_image = strdup(pp); return; } else if(!strcmp(name, "$window_background_mode")) { state->window_background_mode = (int) strtol(p, NULL, 10); return; } else if(!strcmp(name, "$window_background_colour")) { set_window_background_colour(p, lineno); return; } while(isspace(*p)) p++; if(!*p) goto premature; icon = p; while(*p && (!isspace(*p))) p++; if(!*p) goto premature; *p++ = 0; new_litem = my_malloc(sizeof(litem)); if(!(new_litem->name = strdup(name))) { free(new_litem); goto nomem; } if(!(new_litem->icon = strdup(icon))) { free(new_litem->name); free(new_litem); goto nomem; } if(!(new_litem->prog = make_prog_item(p, lineno))) { free(new_litem->name); free(new_litem->icon); free(new_litem); return; } new_litem->iconid = 0; if(strcmp("-", icon)) { li = state->litems; while(li) { if(!(strcmp(icon, li->name))) { new_litem->iconid = li->iconid; break; } li = li->next; } if(!new_litem->iconid) { if(!(new_litem->iconid = GrLoadImageFromFile(icon, 0))){ GrError("Couldn't load icon \"%s\"\n", icon); } else { GrGetImageInfo(new_litem->iconid, &imageinfo); if((imageinfo.width != ICON_WIDTH) || (imageinfo.height != ICON_HEIGHT)) { GrError("Icon \"%s\" is the " "wrong size (%dx%d instead of %dx%d)" "\n", icon, imageinfo.width, imageinfo.height, ICON_WIDTH, ICON_HEIGHT); GrFreeImage(new_litem->iconid); new_litem->iconid = 0; } } } } new_litem->prev = NULL; new_litem->next = NULL; if(!state->litems) { state->lastlitem = new_litem; state->litems = new_litem; } else { new_litem->next = state->litems; state->litems->prev = new_litem; state->litems = new_litem; } state->numlitems++; return; nomem: GrError("Out of memory\n"); exit(1); premature: GrError("Premature end of line on line %d of config file\n", lineno); }
int main(int argc,char **argv) { int t; GR_IMAGE_ID image_id; GR_WINDOW_ID window_id; GR_GC_ID gc_id; GR_SIZE w = -1; GR_SIZE h = -1; GR_EVENT event; GR_SCREEN_INFO sinfo; GR_IMAGE_INFO info; char title[256]; if (argc < 2) { GrError("Usage: nxview [-p] [-s] <image file>\n"); return 1; } t = 1; while ( t < argc ) { if ( !strcmp("-p",argv[t])) { pflag = 1; ++t; continue; } if ( !strcmp("-s",argv[t])) { sflag = 1; ++t; continue; } break; } if (GrOpen() < 0) { GrError("cannot open graphics\n"); return 1; } if (!(image_id = GrLoadImageFromFile(argv[t], 0))) { GrError("Can't load image file: %s\n", argv[t]); return 1; } if(sflag) { /* stretch to half screen size*/ GrGetScreenInfo(&sinfo); w = sinfo.cols/2; h = sinfo.rows/2; } else { GrGetImageInfo(image_id, &info); w = info.width; h = info.height; } sprintf(title, "nxview %s", argv[t]); window_id = GrNewWindowEx(GR_WM_PROPS_APPWINDOW, title, GR_ROOT_WINDOW_ID, 0, 0, w, h, GRAY); GrSelectEvents(window_id, GR_EVENT_MASK_CLOSE_REQ|GR_EVENT_MASK_EXPOSURE); GrMapWindow(window_id); gc_id = GrNewGC(); while (1) { GrGetNextEvent(&event); switch(event.type) { case GR_EVENT_TYPE_CLOSE_REQ: GrDestroyWindow(window_id); GrDestroyGC(gc_id); GrFreeImage(image_id); GrClose(); return 0; /* no return*/ case GR_EVENT_TYPE_EXPOSURE: if (pflag) { int x, y; GR_WINDOW_INFO wi; GrGetWindowInfo(window_id, &wi); for (x=0; x<wi.width; x+=CX*2) for (y=0; y<wi.height; y+=CY) { if (y & CY) GrFillRect(window_id, gc_id, x, y, CX, CY); else GrFillRect(window_id, gc_id, x+CX, y, CX, CY); } } GrDrawImageToFit(window_id, gc_id, 0,0, w,h, image_id); break; } } return 0; }
/* Create a new sprite from the specified image file. Returns the address of * the new sprite on success or 0 on failure. If width is -1, the real * dimensions of the image file will be used, otherwise the image will be * scaled up or down to the specified dimensions. */ sprite *load_sprite(nbstate *state, unsigned char *fname, int width, int height) { sprite *s; GR_DRAW_ID a; GR_DRAW_ID p; GR_IMAGE_ID img; GR_IMAGE_INFO ii; /* Make sure the file name has been specified: */ if (! fname) return 0; /* Try to find a sprite in the list with the specified filename and * dimensions (any dimensions are OK if width is -1). If one is found, * increment its usage count and return its address. */ for(s = state->spritelist; s; s = s->next) { if ((width == -1 || (width == s->w && height == s->h)) && s->fname && !strcmp(fname, s->fname)) { s->usage++; return s; } } #ifdef HAVE_FILEIO { /* Make the full path to the filename because the Nano-X server * probably isn't running from the game data directory: */ char buf[256]; if (snprintf(buf, 256, "%s/%s", state->gamedir, fname) >= 256){ debug_printf ("Warning: image path \"%s/%s\" is too long\n", state->gamedir, fname); return 0; } /* Try to load the image file, and return 0 on failure: */ img = GrLoadImageFromFile (buf, 0); } #else if (strcmp (fname, (unsigned char*) "nbb1.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb1_data, sizeof( nbb1_data), 0); else if (strcmp (fname, (unsigned char*) "nbb2.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb2_data, sizeof( nbb2_data), 0); else if (strcmp (fname, (unsigned char*) "nbb3.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb3_data, sizeof( nbb3_data), 0); else if (strcmp (fname, (unsigned char*) "nbb4.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb4_data, sizeof( nbb4_data), 0); else if (strcmp (fname, (unsigned char*) "nbb5.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb5_data, sizeof( nbb5_data), 0); else if (strcmp (fname, (unsigned char*) "nbb6.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb6_data, sizeof( nbb6_data), 0); else if (strcmp (fname, (unsigned char*) "nbb7.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb7_data, sizeof( nbb7_data), 0); else if (strcmp (fname, (unsigned char*) "nbb8.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb8_data, sizeof( nbb8_data), 0); else if (strcmp (fname, (unsigned char*) "nbb9.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb9_data, sizeof( nbb9_data), 0); else if (strcmp (fname, (unsigned char*)"nbball1.gif") == 0) img = GrLoadImageFromBuffer ((char*)nbball1_data, sizeof(nbball1_data), 0); else if (strcmp (fname, (unsigned char*) "nbbat1.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbat1_data, sizeof( nbbat1_data), 0); else if (strcmp (fname, (unsigned char*) "nbbat2.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbat2_data, sizeof( nbbat2_data), 0); else if (strcmp (fname, (unsigned char*) "nbbat3.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbat3_data, sizeof( nbbat3_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg10.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg10_data, sizeof( nbbg10_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg1.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg1_data, sizeof( nbbg1_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg2.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg2_data, sizeof( nbbg2_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg3.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg3_data, sizeof( nbbg3_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg4.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg4_data, sizeof( nbbg4_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg5.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg5_data, sizeof( nbbg5_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg6.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg6_data, sizeof( nbbg6_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg7.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg7_data, sizeof( nbbg7_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg8.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg8_data, sizeof( nbbg8_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg9.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg9_data, sizeof( nbbg9_data), 0); else if (strcmp (fname, (unsigned char*) "nbpf.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbpf_data, sizeof( nbpf_data), 0); else if (strcmp (fname, (unsigned char*) "nbpn.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbpn_data, sizeof( nbpn_data), 0); else if (strcmp (fname, (unsigned char*) "nbpp.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbpp_data, sizeof( nbpp_data), 0); else if (strcmp (fname, (unsigned char*) "nbps.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbps_data, sizeof( nbps_data), 0); else if (strcmp (fname, (unsigned char*) "nbpt.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbpt_data, sizeof( nbpt_data), 0); else if (strcmp (fname, (unsigned char*) "nbpw.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbpw_data, sizeof( nbpw_data), 0); else if (strcmp (fname, (unsigned char*) "nbsp1.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbsp1_data, sizeof( nbsp1_data), 0); else if (strcmp (fname, (unsigned char*) "nbsp2.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbsp2_data, sizeof( nbsp2_data), 0); else if (strcmp (fname, (unsigned char*) "nbsp3.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbsp3_data, sizeof( nbsp3_data), 0); else { debug_printf ("No such image: \"%s\"\n", fname); uos_halt (0); return 0; } #endif if (! img) { debug_printf ("Warning: failed to load image \"%s\"- make " "sure it is where the server can find it and " "that support for loading the relevant image " "type has been built into the server\n", fname); return 0; } /* If a size wasn't specified, get the real image size from the server * instead: */ if(width == -1 || height == -1) { GrGetImageInfo(img, &ii); width = ii.width; height = ii.height; } /* Make the alpha channel and pixmap to store the image in: */ if(!(a = GrNewPixmap(width, height, 0))) { GrFreeImage(img); return 0; } if(!(p = GrNewPixmap(width, height, 0))) { GrFreeImage(img); GrDestroyWindow(a); return 0; } /* Draw the image into the specified pixmap and alpha channel, scaling * it up or down if necessary: */ GrDrawImageToFit(p, state->gc, 0, 0, width, height, img); GrFreeImage(img); /* Destroy the server image object. */ /* Make a new sprite and link it into the list, then return its * address to the caller: */ s = make_sprite(state, fname, width, height, p, a); if (! s) { GrDestroyWindow(a); GrDestroyWindow(p); return 0; } return s; }
int load_images(void) { char buf[128]; sprintf(buf,"%s/board.gif",IMAGE_PATH); if (!(board_image_id = GrLoadImageFromFile(buf, 0))) { fprintf(stderr, "Can't load board image file\n"); exit(-1); } GrGetImageInfo(board_image_id, &board_info); board_w = board_info.width; board_h = board_info.height; /* ****************/ sprintf(buf,"%s/w_p.gif",IMAGE_PATH); if (!(w_p_image_id = GrLoadImageFromFile(buf, 0))) { fprintf(stderr, "Can't load white pawn image file\n"); exit(-1); } GrGetImageInfo(w_p_image_id, &w_p_info); w_p_w = w_p_info.width; w_p_h = w_p_info.height; /* ****************/ sprintf(buf,"%s/w_n.gif",IMAGE_PATH); if (!(w_n_image_id = GrLoadImageFromFile(buf, 0))) { fprintf(stderr, "Can't load white knight image file\n"); exit(-1); } GrGetImageInfo(w_n_image_id, &w_n_info); w_n_w = w_n_info.width; w_n_h = w_n_info.height; /* ****************/ sprintf(buf,"%s/w_b.gif",IMAGE_PATH); if (!(w_b_image_id = GrLoadImageFromFile(buf, 0))) { fprintf(stderr, "Can't load white bishop image file\n"); exit(-1); } GrGetImageInfo(w_b_image_id, &w_b_info); w_b_w = w_b_info.width; w_b_h = w_b_info.height; /* ****************/ sprintf(buf,"%s/w_r.gif",IMAGE_PATH); if (!(w_r_image_id = GrLoadImageFromFile(buf, 0))) { fprintf(stderr, "Can't load white rook image file\n"); exit(-1); } GrGetImageInfo(w_r_image_id, &w_r_info); w_r_w = w_r_info.width; w_r_h = w_r_info.height; /* ****************/ sprintf(buf,"%s/w_k.gif",IMAGE_PATH); if (!(w_k_image_id = GrLoadImageFromFile(buf, 0))) { fprintf(stderr, "Can't load white king image file\n"); exit(-1); } GrGetImageInfo(w_k_image_id, &w_k_info); w_k_w = w_k_info.width; w_k_h = w_k_info.height; /* ****************/ sprintf(buf,"%s/w_q.gif",IMAGE_PATH); if (!(w_q_image_id = GrLoadImageFromFile(buf, 0))) { fprintf(stderr, "Can't load white queen image file\n"); exit(-1); } GrGetImageInfo(w_q_image_id, &w_q_info); w_q_w = w_q_info.width; w_q_h = w_q_info.height; /* ****************/ sprintf(buf,"%s/b_p.gif",IMAGE_PATH); if (!(b_p_image_id = GrLoadImageFromFile(buf, 0))) { fprintf(stderr, "Can't load black pawn image file\n"); exit(-1); } GrGetImageInfo(b_p_image_id, &b_p_info); b_p_w = b_p_info.width; b_p_h = b_p_info.height; /* ****************/ sprintf(buf,"%s/b_n.gif",IMAGE_PATH); if (!(b_n_image_id = GrLoadImageFromFile(buf, 0))) { fprintf(stderr, "Can't load black knight image file\n"); exit(-1); } GrGetImageInfo(b_n_image_id, &b_n_info); b_n_w = b_n_info.width; b_n_h = b_n_info.height; /* ****************/ sprintf(buf,"%s/b_b.gif",IMAGE_PATH); if (!(b_b_image_id = GrLoadImageFromFile(buf, 0))) { fprintf(stderr, "Can't load black bishop image file\n"); exit(-1); } GrGetImageInfo(b_b_image_id, &b_b_info); b_b_w = b_b_info.width; b_b_h = b_b_info.height; /* ****************/ sprintf(buf,"%s/b_r.gif",IMAGE_PATH); if (!(b_r_image_id = GrLoadImageFromFile(buf, 0))) { fprintf(stderr, "Can't load black rook image file\n"); exit(-1); } GrGetImageInfo(b_r_image_id, &b_r_info); b_r_w = b_r_info.width; b_r_h = b_r_info.height; /* ****************/ sprintf(buf,"%s/b_k.gif",IMAGE_PATH); if (!(b_k_image_id = GrLoadImageFromFile(buf, 0))) { fprintf(stderr, "Can't load black king image file\n"); exit(-1); } GrGetImageInfo(b_k_image_id, &b_k_info); b_k_w = b_k_info.width; b_k_h = b_k_info.height; /* ****************/ sprintf(buf,"%s/b_q.gif",IMAGE_PATH); if (!(b_q_image_id = GrLoadImageFromFile(buf, 0))) { fprintf(stderr, "Can't load black queen image file\n"); exit(-1); } GrGetImageInfo(b_q_image_id, &b_q_info); b_q_w = b_q_info.width; b_q_h = b_q_info.height; return(0); }