Hi,<br>I am new to cairo. i am trying to rotate and scale a image . After doing the transformation i am displaying it in the window, it is shown properly . But when i am saving the surface using "cairo_surface_write_to_png" , the original image is saved again , the changes due to transformation is not reflected. And when i was trying to get the width of scaled surface using "cairo_image_surface_get_width", it is giving the original width only.My code segment is given below.<br>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////<br><br>static gboolean on_expose_event(GtkWidget *widget,GdkEventExpose *event, gpointer data)<br>
{<br> cairo_t *cr;<br>gint width,height;<br><br>cr = gdk_cairo_create (widget->window);<br><br>width = cairo_image_surface_get_width(image);<br>height = cairo_image_surface_get_height(image);<br> <br><br>cairo_translate(cr,width/2,height/2);<br>
<br>cairo_scale(cr,scale_factor,scale_factor);<br><br>cairo_rotate(cr,rotate_angle*M_PI/180.0);<br><br> g_print("rotate_angle %f \n",rotate_angle);<br><br><br>gtk_widget_set_size_request (da, width,height);<br><br>
g_print("width = %d height = %d \n",width,height);<br><br> cairo_set_source_surface(cr, image,-width/2,-height/2);<br><br> cairo_paint(cr);<br> cairo_surface_write_to_png (image, "sticker.png");<br><br>
cairo_destroy(cr);<br><br> return FALSE;<br>}<br><br><br>int main(int argc, char *argv[])<br>{<br> /...../<br><br> image = cairo_image_surface_create_from_png(argv[1]);<br> width = cairo_image_surface_get_width(image);<br>
height = cairo_image_surface_get_height(image);<br> g_print("width = %d height = %d \n",width,height);<br><br>/...../<br><br>da = gtk_drawing_area_new ();<br>gtk_widget_set_size_request (da, width,height);<br>
gtk_fixed_put(GTK_FIXED(fixed),da,50,50);<br>g_signal_connect(da, "expose-event",G_CALLBACK (on_expose_event), NULL);<br><br>/...../<br><br>cairo_surface_destroy(image);<br><br> return 0;<br>}<br clear="all">/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////<br>
<br>Thanks in Advance.<br><br>Regards,<br>Chandra Shekhar Sengupta<br><br>