<div class="gmail_quote"><br><br>Hi,<br><br>i have tried with following code <br><div class="Ih2E3d"><br>tsurf = cairo_get_target(cr);<br></div>cairo_surface_write_to_png (tsurf, "sticker.png");<br><br>but it is saving a zero Byte PNG. Could you tell me where to use "cairo_get_target" api ?<div class="Ih2E3d">
<br>
<br>Thanks in Advance.<br><br>Regards,<br><font color="#888888">Chandra Shekhar Sengupta<br><br>
</font><br></div><div><div></div><div class="Wj3C7c"><div class="gmail_quote">On Wed, Apr 16, 2008 at 3:34 PM, Gerdus van Zyl <<a href="mailto:gerdusvanzyl@gmail.com" target="_blank">gerdusvanzyl@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Its because you are not working with the surface cr is targeting. You need code like <br>tsurf = cairo_get_target(cr); to get the temporary surface GTK is giving you.<br><br>~Gerdus<br><br><div class="gmail_quote"><div><div>
</div><div>On Wed, Apr 16, 2008 at 8:11 AM, Chandra Shekhar Sengupta <<a href="mailto:sayan801@gmail.com" target="_blank">sayan801@gmail.com</a>> wrote:<br>
</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div>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><font color="#888888">Chandra Shekhar Sengupta<br><br>
</font><br></div></div>_______________________________________________<br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org" target="_blank">cairo@cairographics.org</a><br>
<a href="http://lists.cairographics.org/mailman/listinfo/cairo" target="_blank">http://lists.cairographics.org/mailman/listinfo/cairo</a><br></blockquote></div><br>
</blockquote></div><br></div></div></div>