Re: render texts to a buffer/drawable



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.
 
> 		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.

Havoc




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