Hi ,<br>i have tried with adding &quot;get_target&quot; in all possible places, but still &quot;write_png&quot; is saving zero byte png.i have attched the full code . Could you tell how to save that surface?<br><br>////////////////////////////////////////////////////////////////////////////////////////<br>
cairo_surface_t *image,*tsurf;<br>static gdouble rotate_angle = 30.0,scale_factor = 1.5;<br>GtkWidget* da;<br><br><br>static gboolean<br>on_expose_event(GtkWidget *widget,<br>&nbsp;&nbsp;&nbsp; GdkEventExpose *event,<br>&nbsp;&nbsp;&nbsp; gpointer data)<br>
{<br>&nbsp; cairo_t *cr;<br>gint width,height;<br><br>cr = gdk_cairo_create (widget-&gt;window);<br><br>width = cairo_image_surface_get_width(image);<br>height = cairo_image_surface_get_height(image);<br>&nbsp;<br>cairo_translate(cr,width/2,height/2);<br>
cairo_scale(cr,scale_factor,scale_factor);<br>cairo_rotate(cr,rotate_angle*M_PI/180.0);<br><br>gtk_widget_set_size_request (da, width*scale_factor,height*scale_factor);<br><br>&nbsp;cairo_set_source_surface(cr, image,-width/2,-height/2);<br>
&nbsp;cairo_paint(cr);&nbsp;<br>&nbsp;tsurf = cairo_get_target(cr);<br><br>if(cairo_surface_status(tsurf) != CAIRO_STATUS_SUCCESS)<br>&nbsp;g_print(&quot; nil surface \n&quot;);<br>else<br>&nbsp;cairo_surface_write_to_png (tsurf, &quot;sticker.png&quot;);<br>
&nbsp; cairo_destroy(cr);<br><br>&nbsp; return FALSE;<br>}<br><br><br>int main(int argc, char *argv[])<br>{<br>&nbsp; GtkWidget *window;<br>&nbsp; GtkWidget *fixed,*image1;<br>&nbsp; gint width,height;<br><br>&nbsp; image = cairo_image_surface_create_from_png(argv[1]);<br>
&nbsp; width = cairo_image_surface_get_width(image);<br>&nbsp; height = cairo_image_surface_get_height(image);<br>&nbsp;g_print(&quot;width = %d height = %d \n&quot;,width,height);<br><br>&nbsp; gtk_init(&amp;argc, &amp;argv);<br><br>window = gtk_window_new(GTK_WINDOW_TOPLEVEL);<br>
g_signal_connect(window, &quot;destroy&quot;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; G_CALLBACK (gtk_main_quit), NULL);<br>gtk_window_set_default_size(GTK_WINDOW(window), 800, 480); <br>gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);<br>
<br>fixed=gtk_fixed_new();<br>gtk_container_add(GTK_CONTAINER(window),fixed);<br><br>image1=gtk_image_new_from_file(&quot;bg.png&quot;);<br>gtk_fixed_put(GTK_FIXED(fixed),image1,0,0);<br><br>da = gtk_drawing_area_new ();<br>
gtk_widget_set_size_request (da, width*2,height*2);<br>gtk_fixed_put(GTK_FIXED(fixed),da,50,50);<br>g_signal_connect(da, &quot;expose-event&quot;,G_CALLBACK (on_expose_event), NULL);<br>&nbsp;<br>gtk_widget_show_all(window);<br>
<br>gtk_main();<br><br>cairo_surface_destroy(image);<br><br>&nbsp; return 0;<br>}<br>&nbsp;<br>///////////////////////////////////////////////////////////////////<br><br><div class="gmail_quote">On Wed, Apr 16, 2008 at 6:32 PM, Gerdus van Zyl &lt;<a href="mailto:gerdusvanzyl@gmail.com">gerdusvanzyl@gmail.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">You can use get_target anywhere in on_expose, the write_to_png should be where it is now, after all painting is done before destroy. <br>
<div><div></div><div class="Wj3C7c"><br></div></div></blockquote></div>