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

时间:2012-01-27 17:46:21

标签: c xlib

我认为这是用于剪辑的内容,但我找不到任何示例来执行此操作。 我需要:

  • 通过设置新的剪辑遮罩(更改GC)来限制区域
  • 绘制
  • 将GC设置回以前的状态

1 个答案:

答案 0 :(得分:1)

您可以使用XSetClipRectangles()引用hereXSetClipMask()引用here

来执行此操作

所以:

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

相关问题