[Xcb] pixmap from file ?
Sam Varshavchik
mrsam at courier-mta.com
Sun Aug 17 16:10:14 PDT 2014
Patrick writes:
>
> I sort of understand how alpha_surface could be a full fledged pixmap now
> but I still have no clue how to make it an image from disk.
>
> Could anyone point me to an example ? Is it possible to use fopen and just
> read in bytes and assign it to a newly created pixmap?
If the file contains raw pixmap data, sure.
But I'm sure you understand that conventional image formats, like JPG or
PNG, employ sophisticated algorithms to compress the raw image data, in
order to achieve small file sizes. Which must be decompressed, of course,
before loading them into a pixmap.
There are many software libraries that can be used to decode image data, for
particular image formats, like JPG, PNG, and GIF. You can either implement
all those algorithms yourself, of course, or use the libraries. In some way,
you'll end up with raw image data.
Which now must be translated into raw pixmap data. Which puts a new issue on
the table:
pixmap != image.
Traditional X pixmaps are based on color-indexed pixels. So, to put a single
pixel from the image, in a particular color, you'd use xcb_alloc_color() to
allocate a pixel value from the drawable's colormap, that you can put into
your pixmap, for each pixel of the particular color. Later, rinse, repeat,
for every possible color in the image.
In this day and age, this is obviously impractical. The entire pixmap
abstraction dates back to the days with video hardware capable of showing
only a limited number of colors, at the same time. Today's hardware is
capable of displaying any RGB color combination.
Today, the way this is done is to use the render extension, figure out which
pictformats can be used with your drawable (and hope that you're not staring
at a color-indexed pictformat's face), create a picture for the pixmap, then
look up which components of the pictformat correspond to the red, green,
blue, and possibly alpha, channels; then finally map the pixels in the image
into the picture's underlying pixmap.
Either said than done, of course.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20140817/43127dd1/attachment.sig>
More information about the Xcb
mailing list