[cairo] Transform update?
spitzak at gmail.com
Wed Dec 7 09:37:24 PST 2011
Though Cairo does not support it, the way such graphics are drawn is
usually by drawing your sphere as a large number of triangles. For each
triangle a perspective (or possibly just affine) transform of the image
is used. You almost certainly have seen such computer graphics, where a
sphere, if looked at closely, actually consists of many flat triangular
It would be nice if Cairo added a 3x3 matrix transform for the source
surface. Pixman apparently already supports this. This could be used to
get a perspective transform for each triangle and make it possible for
Cairo to draw such 3D graphics. Cairo would also need some changes to
address the fact that it cannot draw triangles joined at the edges and
get what users expect, due to overlapping antialiasing (turning off
antialiasing is not a solution as you want it everywhere else, in
particular in the transformed image).
Both of these I suspect are very low priority for Cairo development
The best way to implement what you want is to directly create the image
yourself. Sending a different transform for each pixel would take far
more code to transmit and interpret this information than it takes for
you to sample the source image yourself and write it to a destination
image. After you have created the destination image you can have Cairo
composite it atop your other graphics.
On 11/27/2011 12:05 PM, Blagoj Kupev wrote:
> I'm now in cairo and this might be already answered, but...
> I'd like to create a image that will be then modified by translation
> using a functionality similar to the cairo_transform function where i'd
> like to define cairo_matrix_t for each pixel. The final idea is to
> modify the image that will be projected to a white ball and after
> reflection it will be a symmetric image.
> I thought that i can do this using cairo_user_to_device function, but
> without any success. First, I'm not sure what is the usage of this
> function, so can anyone help me with the answers to the following
> 1. How to set different cairo_matrix_t for each pixel during the
> translation, the CTM is one for complete image.
> 2. What is the purpose of cairo_to_device function?
> If there's no functionality to define translation using different matrix
> for each pixel, i'd like to add this functionality in cairo...
> So, after i compile the cairo and make new libraries what to do to use
> them? I've succeeded in building the libraries and installing them (i
> can see new library files are copied to /usr/local/lib and other
> places), but i'm not sure if they are really used since modification do
> not seem to be used in the new application.
> The procedure that i'm doing is:
> - modify the cairo_translate function by adding while(1) or other line
> to see if it affects the library.
> - the code is compiled (i know this since if i put invalid line, error
> is reported)
> - sudo make install, to install the libraries
> - i'm recompiling the application that is calling cairo_translate
> function, but the new code is not executed. I'm using the following line
> to compile the application:
> gcc -o transform transform.c `pkg-config --libs --cflags gtk+-2.0`
> What should i do to have new library used? How to debug code in libraries?
> cairo mailing list
> cairo at cairographics.org
More information about the cairo