Exemplo n.º 1
0
// saveCursor saves the pixels under the mouse cursor
void saveCursor(VGImage CursorBuffer, int curx, int cury, int screen_width, int screen_height, int s) {
	int sx, sy, ex, ey;

	sx = curx - s;					   // horizontal 
	if (sx < 0) {
		sx = 0;
	}
	ex = curx + s;
	if (ex > screen_width) {
		ex = screen_width;
	}
	cur_sx = sx;
	cur_w = ex - sx;

	sy = cury - s;					   // vertical 
	if (sy < 0) {
		sy = 0;
	}
	ey = cury + s;
	if (ey > screen_height) {
		ey = screen_height;
	}
	cur_sy = sy;
	cur_h = ey - sy;

	vgGetPixels(CursorBuffer, 0, 0, cur_sx, cur_sy, cur_w, cur_h);
	cur_saved = cur_w * cur_h;
}
Exemplo n.º 2
0
static void
draw(void)
{
   const VGint w = 48;
   VGImage img1, img2;
   VGint x, y;

   vgSetfv(VG_CLEAR_COLOR, 4, white);
   vgClear(0, 0, window_width(), window_height());

   img1 = vgCreateImage(VG_sRGBA_8888, w, w,
         VG_IMAGE_QUALITY_NONANTIALIASED);
   img2 = vgCreateImage(VG_sRGBA_8888, w, w,
         VG_IMAGE_QUALITY_NONANTIALIASED);

   x = 5;
   y = (window_height() - w) / 2;

   /* test vgSetPixels */
   vgSetfv(VG_CLEAR_COLOR, 4, red);
   vgClearImage(img1, 0, 0, w, w / 2);
   vgSetfv(VG_CLEAR_COLOR, 4, black);
   vgClearImage(img1, 0, w / 2, w, w / 2);
   vgSetPixels(x, y, img1, 0, 0, w, w);

   x += w + 5;

   /* test vgDrawImage */
   vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
   vgLoadIdentity();
   vgTranslate(x, y);
   vgDrawImage(img1);

   /* test vgGetPixels */
   vgGetPixels(img1, 0, 0, x, y, w, w);
   x += w + 5;
   vgSetPixels(x, y, img1, 0, 0, w, w);

   x += w + 5;

   /* test vgCopyImage */
   vgCopyImage(img2, 0, 0, img1, 0, 0, w, w, VG_FALSE);
   vgSetPixels(x, y, img2, 0, 0, w, w);

   /* vgCopyPixels */
   vgCopyPixels(x + w + 5, y, x, y, w, w);

   vgDestroyImage(img1);
   vgDestroyImage(img2);
}