示例#1
0
int BC_Capture::get_top_h()
{
	Screen *screen_ptr = XDefaultScreenOfDisplay(display);
	return HeightOfScreen(screen_ptr);
}
示例#2
0
Status XtcwpCreateRGBDefaultMap (Display *dpy, XStandardColormap *scmap)
/*****************************************************************************
create XA_RGB_DEFAULT_MAP property of root window if it does not already exist
******************************************************************************
Input:
dpy		display

Output:
scmap		the standard colormap structure
******************************************************************************
Notes:
This function returns 0 if the XA_RGB_DEFAULT_MAP property does not exist
and cannot be created.  At least 8 contiguous color cells must be free
in the default colormap to create the XA_RGB_DEFAULT_MAP.  If created, the
red_max, green_max, and blue_max values returned in scmap will be equal.
******************************************************************************
Author:  Dave Hale, Colorado School of Mines, 09/29/90
*****************************************************************************/
{
	Screen *scr=XDefaultScreenOfDisplay(dpy);
	Window root=XRootWindowOfScreen(scr);
	Colormap cmap;
	XColor color;
	int i,ncells;
	unsigned long npixels;
	unsigned long bpixel,epixel,pixel1,pixel2,imax,rmult,gmult,bmult;
	unsigned long pixel[4096];

	/* grab the server */
	XGrabServer(dpy);

	/* if XA_RGB_DEFAULT_MAP does not exist, then */
	if (!XGetStandardColormap(dpy,root,scmap,XA_RGB_DEFAULT_MAP)) {
		
		/* use default colormap */
		cmap = DefaultColormapOfScreen(scr);

		/* determine largest number of contiguous free color cells */
		ncells = CellsOfScreen(scr);
		while(ncells && 
			!XAllocColorCells(dpy,cmap,True,NULL,0,pixel,ncells))
			ncells--;
		
		/* determine beginning and ending pixel of contiguous cells */
		for (i=1,bpixel=epixel=pixel1=pixel2=pixel[0]; i<ncells; i++) {
			if (pixel[i]==pixel[i-1]+1)
				pixel2 = pixel[i];
			else
				pixel1 = pixel2 = pixel[i];
			if (pixel2-pixel1>=epixel-bpixel) {
				bpixel = pixel1;
				epixel = pixel2;
			}
		}
		
		/* number of pixels must be at least 8 */
		npixels = epixel-bpixel+1;
		if (npixels<8) {
			XUngrabServer(dpy);
			return 0;
		}
		
		/* force number of contiguous cells to be an integer cubed */
		for (i=2,imax=0; i*i*i<=npixels; i++,imax++);
		npixels = (imax+1)*(imax+1)*(imax+1);
		bpixel = epixel-npixels+1;
		
		/* free cells not in contiguous range */
		for (i=0; i<ncells; i++)
			if (pixel[i]<bpixel || pixel[i]>epixel)
				XFreeColors(dpy,cmap,&pixel[i],1,0);

		/* store colors in contiguous range of allocated cells */
		rmult = (imax+1)*(imax+1);
		gmult = imax+1;
		bmult = 1;
		for (i=0; i<npixels; i++) {
			color.pixel = bpixel+i;
			color.red = (unsigned short) (i/rmult);
			color.green = (unsigned short) ((i-color.red*rmult)/gmult);
			color.blue = (unsigned short) (i-color.red*rmult-color.green*gmult);
			color.red *= 65535/imax;
			color.green *= 65535/imax;
			color.blue *= 65535/imax;
			color.flags = DoRed|DoGreen|DoBlue;
			XStoreColor(dpy,cmap,&color);
		}
		
		/* set standard colormap */
		scmap->colormap = cmap;
		scmap->red_max = imax;
		scmap->green_max = imax;
		scmap->blue_max = imax;
		scmap->red_mult = rmult;
		scmap->green_mult = gmult;
		scmap->blue_mult = bmult;
		scmap->base_pixel = bpixel;
		XSetStandardColormap(dpy,root,scmap,XA_RGB_DEFAULT_MAP);
	}

	/* ungrab the server before returning */
	XUngrabServer(dpy);
	return 1;
}
示例#3
0
int BC_Capture::get_top_w()
{
	Screen *screen_ptr = XDefaultScreenOfDisplay(display);
	return WidthOfScreen(screen_ptr);
}