static void paint_animation(void) { static int pos = 620; static int ini = 0; static GrContext *grc; int ltext, wtext; if (!ini) { grc = GrCreateContext(620, 30, NULL, NULL); if (grc == NULL) return; ini = 1; } grt_left.txo_fgcolor.v = CYAN; grt_left.txo_font = grf_std; ltext = strlen(animatedtext); wtext = GrStringWidth(animatedtext, ltext, &grt_left); GrSetContext(grc); GrClearContext(DARKGRAY); GrDrawString(animatedtext, ltext, pos, 15, &grt_left); GrSetContext(grcglob); GrBitBlt(NULL, 10, 8, grc, 0, 0, 629, 29, GrWRITE); pos -= 1; if (pos <= -wtext) pos = 620; }
/* Copy area (x1,y1)-(x2,y2) from a bitmap (if bm==NULL from the screen) and create a structure ws_bitmap with the area in bitmap. Returns NULL if not successful, the pointer to the structure otherwise. */ struct ws_bitmap *ws_savebitmap(struct ws_bitmap *bm, int x1, int y1, int xsize, int ysize) { GrContext *gc; struct ws_bitmap *bmap; if ( xsize < 0 || ysize < 0 || y1 < 0 || x1 < 0 || x1 + xsize > GrSizeX() || y1 + ysize > GrSizeY() ) { return NULL; } checkmem( bmap = MALLOC( sizeof(struct ws_bitmap) ) ); checkmem( gc = GrCreateContext(xsize, ysize, NULL, NULL) ); GrBitBlt(gc, 0, 0, bm == NULL ? NULL : bm->bitmap, x1, y1, x1 + xsize - 1, y1 + ysize - 1, GrWRITE); bmap->bitmap = (void *)gc; bmap->xpos = x1; bmap->ypos = y1; bmap->xsize = xsize; bmap->ysize = ysize; bmap->w = NULL; return bmap; }
void Init() { listenForEvents(); string imgPath = cur_sim->basePath + "/1booth.jpg"; gc.DrawImage(0, 0, 800, 400, I_JPG, imgPath.c_str()); GrCreateContext(gc.console_width, gc.console_height, NULL, &ctemp); GrBitBlt(&ctemp, 0, 0, NULL, 0, 0, gc.console_width, gc.console_height * (2.0 / 3), GrWRITE); }
/* Create bitmap with bm inside. */ struct ws_bitmap *ws_createbitmap(int xsize, int ysize, char *bm) { GrContext *gc; struct ws_bitmap *bmap; char *mem[4]; if (bm != NULL) { mem[0] = bm; mem[1] = mem[2] = mem[3] = NULL; } if ( xsize < 0 || ysize < 0 || xsize > GrSizeX() || ysize > GrSizeY() ) { return NULL; } if ( ( bmap = MALLOC( sizeof(struct ws_bitmap) ) ) == NULL ) { return NULL; } if ( ( gc = GrCreateContext(xsize, ysize, bm != NULL ? mem : NULL, NULL) ) == NULL ) { FREE(bmap); return NULL; } if (bm == NULL) { GrSetContext(gc); GrClearContext(notes.colindex[cv_winfill]); GrSetContext(NULL); } bmap->bitmap = (void *)gc; bmap->xpos = 0; bmap->ypos = 0; bmap->xsize = xsize; bmap->ysize = ysize; bmap->w = NULL; return bmap; }