XvCreateImage(3)
π XvCreateImage β creating an XvImage, bestie edition π
okay so real quick, this page lives in the libXv Functions section of the manual (third section, (3), we love a library call), and it's about making yourself an XvImage. it's giving "let's build a video image struct together" energy and honestly? iconic. π
β¨ NAME β¨
XvCreateImage, XvShmCreateImage β create an XvImage π
πΈ SYNOPSIS πΈ
#include <X11/extensions/Xvlib.h>
XvImage * XvCreateImage (Display *dpy, XvPortID port,
int id, char *data,
int width, int height);
XvImage * XvShmCreateImage (Display *dpy, XvPortID port,
int id, char *data,
int width, int height,
XShmSegmentInfo *shminfo);
π¦ ARGUMENTS π¦
dpyβ the connection to the X server. your whole link-up, basically.portβ the port thisXvImageis gonna be used with.idβ the format of the image you're creating, given as anXvImageFormatValuesid.dataβ the image data. yes, the actual pixels-in-waiting.width,heightβ the width and height you want the image to be. your desired dimensions, no cap.
π DESCRIPTION π
XvCreateImage(3) is like XCreateImage(3)'s little sibling, and XvShmCreateImage(3) is the same deal but matched up with XShmCreateImage(3). fr fr, same vibe, different extension.
so here's the tea: the library allocates the XvImage structure and fills out every single field β except data. every field but that one. π
also heads up, width and height may get enlarged in some YUV formats. so don't come for the library when your numbers come back bigger. the size of the data buffer you actually need to allocate will be handed to you in the data_size field of the XvImage.
and no, image data is NOT allocated by this function. not even a little. so you've got options:
- pass a pointer to memory you already preallocated as
data, or - let the server fill out the
data_sizefield first, then allocate the memory and fill in theXvImagestructure'sdatafield yourself.
either way, you're the one doing the allocating. main character responsibilities, unfortunately. π
when you're done with it, the XvImage structure can be freed with XFree(3). and shared memory segments? those get attached/detached with XShmAttach(3) / XShmDetach(3). keep those paired, bestie, it's a whole thing. π«Ά
π₯ RETURN VALUES π₯
XvImage has this structure, and it's exactly this:
typedef struct {
int id;
int width, height;
int data_size;
int num_planes;
int *pitches;
int *offsets;
char *data;
XPointer obdata;
} XvImage;
and here's what every field is doing:
idβ a descriptor for the format, from theXvImageFormatValuesstructure thatXvListImageFormats(3)hands back.width,heightβ the width and height of the image in pixels.data_sizeβ the size of the data buffer, in bytes.num_planesβ how many image planes there are.pitchesβ an array of sizenum_planesshowing the scanline pitch in bytes. and bestie, each plane can have a different pitch. they're all individuals. β¨offsetsβ an array of sizenum_planesshowing the byte offset fromdatato the start of each plane.dataβ a pointer to the start of the data buffer.obdataβ a private field for holding SHM info. the client libraries set this one up for you, so honestly the programmer generally doesn't need to worry about it at all. it's giving "don't perceive me". π
β DIAGNOSTICS β
[XvBadPort]β generated if the port you asked for does not exist. she's not there, bestie.[XvBadAlloc]β generated if the X server couldn't allocate the resources it needed to finish the operation. the server is going through it. π[BadMatch]β generated if you supplied incompatible arguments β like a port that isn't capable of displayingXvImages. wrong port for the job, ngl.
π SEE ALSO π
XvListImageFormats(3), XCreateImage(3), XShmCreateImage(3), XShmAttach(3), XShmDetach(3).
the whole friend group, go read them too. π
okay and that's the page!! π§ this one shipped with X Version 11, from libXv 1.0.13, and it's XvCreateImage(3) if you're trying to find it again β slay, go make some images, you've got this. πβ¨
π¦ where this page comes from
- alpine 3.22: libxv-doc 1.0.13-r0 Β· MIT
- alpine 3.23: libxv-doc 1.0.13-r0 Β· MIT
- alpine 3.24: libxv-doc 1.0.13-r0 Β· MIT
- arch rolling: libxv 1.0.13-1 Β· SMLNJ AND HPND-sell-variant
- fedora 43: libXv-devel 1.0.13-3.fc43 Β· SMLNJ AND HPND-sell-variant
- fedora 43: libXv-devel 1.0.13-3.fc43 Β· SMLNJ AND HPND-sell-variant
- fedora 44: libXv-devel 1.0.13-4.fc44 Β· SMLNJ AND HPND-sell-variant
- fedora 44: libXv-devel 1.0.13-4.fc44 Β· SMLNJ AND HPND-sell-variant
- ubuntu resolute: libxv-dev 2:1.0.13-1 Β· MIT
- ubuntu stonking: libxv-dev 2:1.0.13-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms