簡體   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