繁体   English   中英

如何限制Xlib图形基元绘制的表面?

[英]How can I limit the surface in which Xlib graphics primitives draw?

我认为这就是剪辑的用途,但我找不到任何示例可以做到这一点。 我需要:

  • 通过设置新的剪贴蒙版(更改GC)来限制区域
  • 将GC恢复到先前的状态

您可以通过做XSetClipRectangles()引用在这里XSetClipMask()引用在这里

所以:

Display dpy; //This is your display, we'll assume it is a valid Display
GC gc; //This is your GC, we'll assume it is a valid GC
XRectangle recs[]; //This is an array containing the clipping regions you want.
int recs_n; //This is the number of rectangles in the 'recs' array.

XSetClipRectangles(dpy, gc, 0, 0, recs, recs_n, Unsorted); //Enable clipping
drawMyClippedGraphics(); //Call to whatever you want to use for drawing
XSetClipMask(dpy, gc, None); //Restore the GC

有关更多信息,请在终端中输入man functionName

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM