Re: render texts to a buffer/drawable



Havoc Pennington wrote:

Ronald Bultje <rbultje ronald bitfreak net> writes:

		pixmap = gdk_pixmap_new(NULL, w, h, 24);


Not sure if you are trying to be portable across machines, but this
could easily fail, not all X servers have 24-bit.

Uhm... Never thought about that, really :-)
Is there any way to get a 24-bit drawable form the server on non-24-bit X-servers?

Is it possible at all to have 24-bit drawables on non-24-bit X-servers?

Or would I haev to use something else (client-side) for this? (like freetype, as John suggested).

		for (y=0;y<h;y++)
		{
			for (x=0;x<w;x++)
			{
				pixel = gdk_image_get_pixel(image,x,y);
				data[(y*w+x)*4] = pixel/(256^3);
				data[(y*w+x)*4+1] = (pixel/(256^2))%256;
				data[(y*w+x)*4+2] = (pixel/256)%(256^2);
				data[(y*w+x)*4+3] = 255;
			}
		}


Here you're assuming far more than you reasonably can about the image
format.
gdk_pixbuf_get_from_drawable() does this for you and handles all the
image formats and bit depths.

The problem I encountered with gdk_pixbuf_from_drawable is that it needed a colormap. However, trying to get a colormap from the pixmap resulted in an error that it could not get a colormap from a pixmap....

Or should I use gdk_colormap_get_system() (which could be different from the colormap of the pixmap...)?

Regards,

Ronald





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]