Hi All,<br><br>I have written a new "effect" for geometrictransform. It does image rotation.<br>The code is appended below.<br>If there is any interest, I will do the work to push it upstream.<br>But I need a mentor to help guide the way.<br>
<br>On the code itself.<br>I modified the "circle" element, to do rotation.<br>The changes were confined to the "map" function.<br>I used the same parameters, but with different meaning.<br><br>Thanks,<br>
Bert Douglas<br><br>------------------------------------------------------------------------<br><br>static gboolean<br>circle_map (GstGeometricTransform * gt, gint x, gint y, gdouble * in_x,<br> gdouble * in_y)<br>{<br>
//GstCircleGeometricTransform *cgt = GST_CIRCLE_GEOMETRIC_TRANSFORM_CAST (gt);<br> GstCircle *circle = GST_CIRCLE_CAST (gt);<br><br> gint w, h;<br> gdouble pad, sa;<br> gdouble cix, ciy, cox, coy; // centers, in/out x/y<br>
gdouble ai, ao, ar; // angles, in/out/rotate (radians)<br> gdouble r; // radius<br> gdouble xi, yi, xo, yo; // positions in/out x/y<br><br> // input and output image height and width<br>
w = gt->width;<br> h = gt->height;<br><br> // our parameters<br> pad = circle->height; // padding on bottom and right of input image<br> ar = circle->angle * M_PI / 180.0; // angle of rotation, degrees to radians<br>
sa = circle->spread_angle; // not used<br><br> // get in and out centers<br> cox = 0.5 * w;<br> coy = 0.5 * h;<br> cix = 0.5 * (w - pad);<br> ciy = 0.5 * (h - pad);<br><br> // convert output image position to polar form<br>
xo = x - cox;<br> yo = y - coy;<br> ao = atan2 (yo, xo);<br> r = sqrt (xo * xo + yo * yo);<br><br> // perform rotation backward to get input image rotation<br> // this seems wrong, but rotation from in-->out is counterclockwise<br>
ai = ao + ar;<br><br> // back to rectangular for input image position<br> xi = r * cos (ai);<br> yi = r * sin (ai);<br><br> // restore center offset, return values to caller<br> *in_x = xi + cix;<br> *in_y = yi + ciy;<br>
<br> GST_DEBUG_OBJECT (circle, "Inversely mapped %d %d into %lf %lf",<br> x, y, *in_x, *in_y);<br><br> return TRUE;<br>}<br><br><br><br><br>