Render transformation matrix

Owen Taylor otaylor at redhat.com
Wed Jan 26 05:53:07 PST 2005


On Wed, 2005-01-26 at 14:35 +0100, Damien Ciabrini wrote:

> I'm trying to add support for the Render transformation matrix for the 
> Kdrive mga driver, and I'd like to know if I understood the problem 
> correctly.
> 
> In a user program, I want to composite a Picture with a certain zoom 
> factor. I do it with the following piece of code:
> 
>   XRenderSetPictureTransform(dpy,icon_pic,&xform);
>   // XRenderSetPictureFilter(dpy,icon_pic,FilterBilinear, 0, 0);
>   XRenderComposite(dpy,composite_op,icon_pic, 0, back_buffer_pic,
>                    0, 0, 0, 0, zoomed_x[i],zoomed_y[i],
> 		  zoomed_size[i],zoomed_size[i]);
> and this is my transformation matrix:
>    XTransform xform = {{
> 	{ 1.0f, 0.0f, 0.0f },
> 	{ 0.0f, 1.0f, 0.0f },
> 	{ 0.0f, 0.0f, 2.0f }
>    }};
> I assume it would give the same result with the following matrix:
>    XTransform xform = {{
> 	{ 2.0f, 0.0f, 0.0f },
> 	{ 0.0f, 2.0f, 0.0f },
> 	{ 0.0f, 0.0f, 1.0f }
>    }};

Are you actually passing in floating point values, or is the
above just a shorthand? (the code above will give you matrices that 
are off by a factor of 65536.. you need to use XDoubleToFixed)

But in any case, the two matrices aren't equivalent ... I'm pretty
sure that the code just ignores the 3rd line of the transform,
since the code isn't really dealing with homogeneous coordinates,
but if it wasn't, then the first matrix applied to [1,0,1] would
give [1,0,2] which is equivalent to [0.5,0,1]. The second 
gives [2,0,1].

So, this may not be your question, but if I wanted to zoom a picture
by a factor of s, I'd use the matrix

 DoubleToFixed(1/s), 0,                  0
 0,                  DoubleToFixed(1/s), 0
 0,                  0,                  1

It's 1/s since the matrix transforms from destination coordinates to
source coordinates.

Regards,
						Owen

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.x.org/archives/xorg/attachments/20050126/c7438226/attachment.pgp>


More information about the xorg mailing list