本文整理汇总了C++中DisplayWidthMM函数的典型用法代码示例。如果您正苦于以下问题:C++ DisplayWidthMM函数的具体用法?C++ DisplayWidthMM怎么用?C++ DisplayWidthMM使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DisplayWidthMM函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open_display
/*
* Pøipojit k serveru, zjistit o nìm informace
*/
static void open_display(void)
{
display_name = XDisplayName(NULL);
if(!(display = XOpenDisplay(display_name))) {
fprintf(stderr, "Cannot connect to X server \"%s\"\n", display_name);
exit(1);
}
debug("Connected to X server \"%s\"\n", display_name);
screen_num = DefaultScreen(display);
screen = DefaultScreenOfDisplay(display);
debug("Default screen number is %d\n", screen_num);
screen_width = DisplayWidth(display, screen_num);
screen_height = DisplayHeight(display, screen_num);
screen_width_mm = DisplayWidthMM(display, screen_num);
screen_height_mm = DisplayHeightMM(display, screen_num);
debug("Screen size is %ux%u pixels, %ux%u mm\n", screen_width,
screen_height, screen_width_mm, screen_height_mm);
root = RootWindow(display, screen_num);
black = BlackPixel(display, screen_num);
white = WhitePixel(display, screen_num);
debug("Root window ID is %#lx, black is %#lx, white is %#lx\n", root,
black, white);
def_gc = DefaultGC(display, screen_num);
/* Toto volání XQueryFont() do def_font->fid neulo¾í ID fontu, ale
* grafického kontextu! Nevím, jak získat ID nebo jméno standardního
* fontu. */
if(!(def_font = XQueryFont(display, XGContextFromGC(def_gc)))) {
fprintf(stderr, "XQueryFont() failed\n");
exit(1);
}
}
示例2: XOpenDisplay
NS_CC_BEGIN
int CCDevice::getDPI()
{
static int dpi = -1;
if (dpi == -1)
{
Display *dpy;
char *displayname = NULL;
int scr = 0; /* Screen number */
dpy = XOpenDisplay (displayname);
/*
* there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
*
* dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch))
* = N pixels / (M inch / 25.4)
* = N * 25.4 pixels / M inch
*/
double xres = ((((double) DisplayWidth(dpy,scr)) * 25.4) /
((double) DisplayWidthMM(dpy,scr)));
dpi = (int) (xres + 0.5);
//printf("dpi = %d\n", dpi);
}
return dpi;
}
示例3: open_display
/*
* Pøipojit k serveru, zjistit o nìm informace
*/
static void open_display(void)
{
display_name = XDisplayName(NULL);
if(!(display = XOpenDisplay(display_name))) {
fprintf(stderr, "Cannot connect to X server \"%s\"\n", display_name);
exit(1);
}
debug("Connected to X server \"%s\"\n", display_name);
screen_num = DefaultScreen(display);
screen = DefaultScreenOfDisplay(display);
debug("Default screen number is %d\n", screen_num);
screen_width = DisplayWidth(display, screen_num);
screen_height = DisplayHeight(display, screen_num);
screen_width_mm = DisplayWidthMM(display, screen_num);
screen_height_mm = DisplayHeightMM(display, screen_num);
debug("Screen size is %ux%u pixels, %ux%u mm\n", screen_width,
screen_height, screen_width_mm, screen_height_mm);
root = RootWindow(display, screen_num);
black = BlackPixel(display, screen_num);
white = WhitePixel(display, screen_num);
debug("Root window ID is %#lx, black is %#lx, white is %#lx\n", root,
black, white);
def_gc = DefaultGC(display, screen_num);
if(!(def_font = XQueryFont(display, XGContextFromGC(def_gc)))) {
fprintf(stderr, "XQueryFont() failed\n");
exit(1);
}
}
示例4: XOpenDisplay
float X11Display::queryPPMM()
{
::Display * pDisplay = XOpenDisplay(0);
float ppmm = getScreenResolution().x/float(DisplayWidthMM(pDisplay, 0));
XCloseDisplay(pDisplay);
return ppmm;
}
示例5: calcDisplayDensity
static float calcDisplayDensity()
{
const char* current_display = getenv("DISPLAY");
if (current_display != NULL) {
Display * x11display = XOpenDisplay(current_display);
if (x11display != NULL) {
/* try x direct */
float dpi_height =
floor(DisplayHeight(x11display, 0) /
(DisplayHeightMM(x11display, 0) * 0.039370) + 0.5);
float dpi_width =
floor(DisplayWidth(x11display, 0) /
(DisplayWidthMM(x11display, 0) * 0.039370) +0.5);
XCloseDisplay(x11display);
return std::max(dpi_height,dpi_width) / 96.0;
}
}
/* return manually specified dpi */
return g_settings->getFloat("screen_dpi")/96.0;
}
示例6: cdGetScreenSize
void cdGetScreenSize(int *width, int *height, double *width_mm, double *height_mm)
{
static int first = 1;
static int dpy_width, dpy_height, dpy_width_mm, dpy_height_mm;
if (first)
{
Display* drv_display = XOpenDisplay(NULL);
int drv_screen = DefaultScreen (drv_display);
dpy_width = DisplayWidth(drv_display,drv_screen);
dpy_height = DisplayHeight(drv_display,drv_screen);
dpy_width_mm = DisplayWidthMM(drv_display,drv_screen);
dpy_height_mm = DisplayHeightMM(drv_display,drv_screen);
XCloseDisplay(drv_display);
first = 0;
}
if (width) *width = dpy_width;
if (height) *height = dpy_height;
if (width_mm) *width_mm = dpy_width_mm;
if (height_mm) *height_mm = dpy_height_mm;
}
示例7: x11_get_metrics
bool x11_get_metrics(void *data,
enum display_metric_types type, float *value)
{
unsigned screen_no = 0;
Display *dpy = (Display*)XOpenDisplay(NULL);
int pixels_x = DisplayWidth(dpy, screen_no);
int pixels_y = DisplayHeight(dpy, screen_no);
int physical_width = DisplayWidthMM(dpy, screen_no);
int physical_height = DisplayHeightMM(dpy, screen_no);
(void)pixels_y;
XCloseDisplay(dpy);
switch (type)
{
case DISPLAY_METRIC_MM_WIDTH:
*value = (float)physical_width;
break;
case DISPLAY_METRIC_MM_HEIGHT:
*value = (float)physical_height;
break;
case DISPLAY_METRIC_DPI:
*value = ((((float)pixels_x) * 25.4) / ((float)physical_width));
break;
case DISPLAY_METRIC_NONE:
default:
*value = 0;
return false;
}
return true;
}
示例8: dpy
XRRConfiguration::XRRConfiguration(Display *_dpy, Window _win)
: dpy(_dpy)
, win(_win)
, screenResources(nullptr), outputInfo(nullptr), crtcInfo(nullptr)
, fullMode(0)
, fs_fb_width(0), fs_fb_height(0), fs_fb_width_mm(0), fs_fb_height_mm(0)
, bValid(true), bIsFullscreen(false)
{
int XRRMajorVersion, XRRMinorVersion;
if (!XRRQueryVersion(dpy, &XRRMajorVersion, &XRRMinorVersion) ||
(XRRMajorVersion < 1 || (XRRMajorVersion == 1 && XRRMinorVersion < 3)))
{
WARN_LOG(VIDEO, "XRRExtension not supported.");
bValid = false;
return;
}
screenResources = XRRGetScreenResourcesCurrent(dpy, win);
screen = DefaultScreen(dpy);
fb_width = DisplayWidth(dpy, screen);
fb_height = DisplayHeight(dpy, screen);
fb_width_mm = DisplayWidthMM(dpy, screen);
fb_height_mm = DisplayHeightMM(dpy, screen);
INFO_LOG(VIDEO, "XRRExtension-Version %d.%d", XRRMajorVersion, XRRMinorVersion);
Update();
}
示例9: locker
QSize MythXDisplay::GetDisplayDimensions(void)
{
MythXLocker locker(this);
int displayWidthMM = DisplayWidthMM( m_disp, m_screen_num);
int displayHeightMM = DisplayHeightMM(m_disp, m_screen_num);
return QSize(displayWidthMM, displayHeightMM);
}
示例10: getSystemContentScale
// Retrieve system content scale via folklore heuristics
//
static void getSystemContentScale(float* xscale, float* yscale)
{
// NOTE: Fall back to the display-wide DPI instead of RandR monitor DPI if
// Xft.dpi retrieval below fails as we don't currently have an exact
// policy for which monitor a window is considered to "be on"
float xdpi = DisplayWidth(_glfw.x11.display, _glfw.x11.screen) *
25.4f / DisplayWidthMM(_glfw.x11.display, _glfw.x11.screen);
float ydpi = DisplayHeight(_glfw.x11.display, _glfw.x11.screen) *
25.4f / DisplayHeightMM(_glfw.x11.display, _glfw.x11.screen);
// NOTE: Basing the scale on Xft.dpi where available should provide the most
// consistent user experience (matches Qt, Gtk, etc), although not
// always the most accurate one
char* rms = XResourceManagerString(_glfw.x11.display);
if (rms)
{
XrmDatabase db = XrmGetStringDatabase(rms);
if (db)
{
XrmValue value;
char* type = NULL;
if (XrmGetResource(db, "Xft.dpi", "Xft.Dpi", &type, &value))
{
if (type && strcmp(type, "String") == 0)
xdpi = ydpi = atof(value.addr);
}
XrmDestroyDatabase(db);
}
}
*xscale = xdpi / 96.f;
*yscale = ydpi / 96.f;
}
示例11: wxDisplaySizeMM
void wxDisplaySizeMM(int *width, int *height)
{
Display *dpy = (Display*) wxGetDisplay();
if ( width )
*width = DisplayWidthMM(dpy, DefaultScreen (dpy));
if ( height )
*height = DisplayHeightMM(dpy, DefaultScreen (dpy));
}
示例12: gst_vaapi_display_x11_get_size_mm
static void
gst_vaapi_display_x11_get_size_mm(
GstVaapiDisplay *display,
guint *pwidth,
guint *pheight
)
{
GstVaapiDisplayX11Private * const priv =
GST_VAAPI_DISPLAY_X11(display)->priv;
guint width_mm, height_mm;
if (!priv->x11_display)
return;
width_mm = DisplayWidthMM(priv->x11_display, priv->x11_screen);
height_mm = DisplayHeightMM(priv->x11_display, priv->x11_screen);
#ifdef HAVE_XRANDR
/* XXX: fix up physical size if the display is rotated */
if (priv->use_xrandr) {
XRRScreenConfiguration *xrr_config = NULL;
XRRScreenSize *xrr_sizes;
Window win;
int num_xrr_sizes, size_id, screen;
Rotation rotation;
do {
win = DefaultRootWindow(priv->x11_display);
screen = XRRRootToScreen(priv->x11_display, win);
xrr_config = XRRGetScreenInfo(priv->x11_display, win);
if (!xrr_config)
break;
size_id = XRRConfigCurrentConfiguration(xrr_config, &rotation);
if (rotation == RR_Rotate_0 || rotation == RR_Rotate_180)
break;
xrr_sizes = XRRSizes(priv->x11_display, screen, &num_xrr_sizes);
if (!xrr_sizes || size_id >= num_xrr_sizes)
break;
width_mm = xrr_sizes[size_id].mheight;
height_mm = xrr_sizes[size_id].mwidth;
} while (0);
if (xrr_config)
XRRFreeScreenConfigInfo(xrr_config);
}
#endif
if (pwidth)
*pwidth = width_mm;
if (pheight)
*pheight = height_mm;
}
示例13: StripMisc_init
/*
* StripMisc_init
*
* Initializes global constants.
*/
void StripMisc_init (Display *display, int screen)
{
horizontal_pixels_per_mm =
((float)DisplayWidth(display, screen) /
(float)DisplayWidthMM(display, screen));
vertical_pixels_per_mm =
((float)DisplayHeight(display, screen) /
(float)DisplayHeightMM(display, screen));
}
示例14: x11_init
int x11_init(GraceApp *gapp)
{
X11Stuff *xstuff = gapp->gui->xstuff;
XGCValues gc_val;
long mrsize;
int max_path_limit;
xstuff->screennumber = DefaultScreen(xstuff->disp);
xstuff->root = RootWindow(xstuff->disp, xstuff->screennumber);
xstuff->gc = DefaultGC(xstuff->disp, xstuff->screennumber);
xstuff->depth = DisplayPlanes(xstuff->disp, xstuff->screennumber);
/* init colormap */
xstuff->cmap = DefaultColormap(xstuff->disp, xstuff->screennumber);
/* redefine colormap, if needed */
if (gapp->gui->install_cmap == CMAP_INSTALL_ALWAYS) {
xstuff->cmap = XCopyColormapAndFree(xstuff->disp, xstuff->cmap);
gapp->gui->private_cmap = TRUE;
}
/* set GCs */
if (gapp->gui->invert) {
gc_val.function = GXinvert;
} else {
gc_val.function = GXxor;
}
gcxor = XCreateGC(xstuff->disp, xstuff->root, GCFunction, &gc_val);
/* XExtendedMaxRequestSize() appeared in X11R6 */
#if XlibSpecificationRelease > 5
mrsize = XExtendedMaxRequestSize(xstuff->disp);
#else
mrsize = 0;
#endif
if (mrsize <= 0) {
mrsize = XMaxRequestSize(xstuff->disp);
}
max_path_limit = (mrsize - 3)/2;
if (max_path_limit < get_max_path_limit(grace_get_canvas(gapp->grace))) {
char buf[128];
sprintf(buf,
"Setting max drawing path length to %d (limited by the X server)",
max_path_limit);
errmsg(buf);
set_max_path_limit(grace_get_canvas(gapp->grace), max_path_limit);
}
xstuff->dpi = rint(MM_PER_INCH*DisplayWidth(xstuff->disp, xstuff->screennumber)/
DisplayWidthMM(xstuff->disp, xstuff->screennumber));
return RETURN_SUCCESS;
}
示例15: DisplayWidth
/* Xlib font utils define */
static XFontStruct *LoadQueryScalableFont (Display * dpy, int screen, char *name, int size)
{
int i, j, field;
char newname[500]; /* big enough for a long font name */
int res_x, res_y; /* resolution values for this screen */
/* catch obvious errors */
if ((name == NULL) || (name[0] != '-'))
return NULL;
/* calculate our screen resolution in dots per inch. 25.4mm = 1 inch */
res_x = DisplayWidth (dpy, screen) / (DisplayWidthMM (dpy, screen) / 25.4);
res_y = DisplayHeight (dpy, screen) / (DisplayHeightMM (dpy, screen) / 25.4);
/* copy the font name, changing the scalable fields as we do so */
for (i = j = field = 0; name[i] != '\0' && field <= 14; i++)
{
newname[j++] = name[i];
if (name[i] == '-')
{
field++;
switch (field)
{
case 7: /* pixel size */
case 12: /* average width */
/* change from "-0-" to "-*-" */
newname[j] = '*';
j++;
if (name[i + 1] != '\0')
i++;
break;
case 8: /* point size */
/* change from "-0-" to "-<size>-" */
sprintf (&newname[j], "%d", size);
while (newname[j] != '\0')
j++;
if (name[i + 1] != '\0')
i++;
break;
case 9: /* x-resolution */
case 10: /* y-resolution */
/* change from an unspecified resolution to res_x or res_y */
sprintf (&newname[j], "%d", (field == 9) ? res_x : res_y);
while (newname[j] != '\0')
j++;
while ((name[i + 1] != '-') && (name[i + 1] != '\0'))
i++;
break;
}
}
}
newname[j] = '\0';
/* if there aren't 14 hyphens, it isn't a well formed name */
if (field != 14)
return NULL;
return XLoadQueryFont (dpy, newname);
}