I am using X-window (X11) to render 2D graphics (lines, circles, text...). But rather than drawing to a window, I need to draw to an existing bitmap image. Is there a way to achieve this ? If yes, are there restrictions on the bitmap format ?
(Notice: I am not trying to render an image to a window.)
CodePudding user response:
- Create a pixmap via: XCreatePixmap
- Create a context via XCreateGC, specifying the pixmap as the drawable.
- Transfer the contents of your existing image via XPutImage (see also Transferring Images between Client and Server), specifying the pixmap as the drawable and the related context.
- do your renderings via GC Convenience Routines and Graphics Functions
- Get the contents from the pixmap via: XGetImage, see also Transferring Images between Client and Server
- Save the image data.