Exemplo n.º 1
0
/* set_clip:
 *  Sets the two opposite corners of the clipping rectangle to be used when
 *  drawing to the bitmap. Nothing will be drawn to positions outside of this 
 *  rectangle. When a new bitmap is created the clipping rectangle will be 
 *  set to the full area of the bitmap. If x1, y1, x2 and y2 are all zero 
 *  clipping will be turned off, which will slightly speed up drawing 
 *  operations but will allow memory to be corrupted if you attempt to draw 
 *  off the edge of the bitmap.
 */
void set_clip(BITMAP *bitmap, int x1, int y1, int x2, int y2)
{
   int t;

   ASSERT(bitmap);

   if ((!x1) && (!y1) && (!x2) && (!y2)) {
      set_clip_rect(bitmap, 0, 0, bitmap->w-1, bitmap->h-1);
      set_clip_state(bitmap, FALSE);
      return;
   }

   if (x2 < x1) {
      t = x1;
      x1 = x2;
      x2 = t;
   }

   if (y2 < y1) {
      t = y1;
      y1 = y2;
      y2 = t;
   }

   set_clip_rect(bitmap, x1, y1, x2, y2);
   set_clip_state(bitmap, TRUE);
}
Exemplo n.º 2
0
/* fudge_bitmap:
 *  Makes b2 be similar to b1 (duplicate clip settings, ID, etc).
 */
static void fudge_bitmap(BITMAP *b1, BITMAP *b2, int copy)
{
   int s, x1, y1, x2, y2;

   set_clip_state(b2, FALSE);

   if (copy)
      blit(b1, b2, 0, 0, 0, 0, b1->w, b1->h);

   get_clip_rect(b1, &x1, &y1, &x2, &y2);
   s = get_clip_state(b1);

   set_clip_rect(b2, x1, y1, x2, y2);
   set_clip_state(b2, s);
}
Exemplo n.º 3
0
BITMAP *set_screen(int fullscreen)
{
	const unsigned char
	vgargb[16][3] = {
		  0,  0,  0,	/* 0 black */
		170,  0,  0,	/* 1 red */
		  0,170,  0, 	/* 2 green */
		170, 85,  0, 	/* 3 yellow */
		  0,  0,170,	/* 4 blue */
		170,  0,170,	/* 5 magenta */
		  0,170,170,	/* 6 cyan */
		170,170,170,	/* 7 white */
		 85, 85, 85,
		255, 85, 85,
		 85,255, 85,
		255,255, 85,
		 85, 85,255,
		255, 85,255,
		 85,255,255,
		255,255,255
	};
	const unsigned char *rgb;
	if (!setgfxmode(fullscreen))
		exit(1);
	clear_bitmap(screen);
	if (set_display_switch_callback(SWITCH_IN, got_focus_back) == -1)
		set_display_switch_mode(SWITCH_PAUSE);
	BITMAP *bmp = create_bitmap(8 * term_width, 400);
	clear_bitmap(bmp);
	set_clip_state(bmp, 0);
	set_clip_state(screen, 0);
	int i;
	for (i=0; i<16; i++) {
		rgb = &vgargb[i][0];
		vgacolors[i] = makecol(rgb[0], rgb[1], rgb[2]);
	}
	return bmp;
}