<br>I am having trouble rendering an ImageSurface to an X11 display.&nbsp; My problem seems to be with only certain sizes and may possibly be related to my graphics card and driver.<br><br>In the code below, I took the &quot;Image&quot; snippet from the cairo-demo package and broke it out into a simple program.&nbsp; 
<br><br>I then took the png file &quot;romedalen.png&quot; and sc.aled and saved it using Gimp such that I had a total of five files of pixel sizes 100x100, 256x192(original size), 300x300, 400x300, and 400x400.<br><br>(BTW, the cairo_snippets_gtk program is presently broken due to API changes.&nbsp; I have included patches at the bottom of this message.)
<br><br>I found that some files would display properly and some would not.&nbsp; I also found that it seemed to be related to the display and graphics card.&nbsp; Here are the results:<br><br>ATI Radeon 9000 with dual screen using ati driver:
<br>screen 0: 1400x1050<br>works: 256x192, 100x100,<br>doesn't work: 400x400, 300x300, 400x300<br><br>screen 1: 1600x1200<br>works: 256x192, 400x400, 100x100<br>doesn't work: 300x300, 400x300<br><br>NVIDIA on&nbsp; 1280x1024 using nvidia driver
<br>works: 100x100, 256x192, 300x300, 400x300, 400x400<br>doesn't work: <br><br>I get the same results with cairo-1.0.4 and cairo-1.2.0.<br>Can anyone tell me what is wrong?&nbsp; Is this a cairo bug?<br><br>Thanks<br>Bob Gibbs
<br><br><br>/*********************** START SIMPLE PROGRAM ***************************/
<br>#include &lt;math.h&gt;<br>#include &lt;cairo.h&gt;<br>#include &lt;gtk/gtk.h&gt;<br><br>/*cc `pkg-config gtk+-2.0 --cflags --libs` test-png.c */<br><br>#define WINDOW_WIDTH 400<br>#define WINDOW_HEIGHT 400<br><br>static cairo_surface_t *surface;
<br><br>static void<br>create_surface()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; surface = cairo_image_surface_create_from_png (&quot;romedalen5.png&quot;);<br>}<br><br>static void<br>snippet_normalize (cairo_t *cr, double width, double height)<br>

{<br>&nbsp;&nbsp;&nbsp; cairo_scale (cr, width, height);<br>&nbsp;&nbsp;&nbsp; cairo_set_line_width (cr, 0.04);<br>}<br><br>static void<br>do_blit(cairo_t *cr)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int w, h;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; snippet_normalize (cr, WINDOW_WIDTH, WINDOW_HEIGHT);
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; w = cairo_image_surface_get_width (surface);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; h = cairo_image_surface_get_height (surface);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;w=%d, h=%d\n&quot;, w, h);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_translate (cr, 0.5, 0.5);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_rotate (cr, 45* M_PI/180);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_scale&nbsp; (cr, 1.0/w, 1.0/h);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_translate (cr, -0.5*w, -0.5*h);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_set_source_surface (cr, surface, 0, 0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_paint (cr);<br>}<br><br>static void<br>paint(GtkWidget *w, GdkEvent *event)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_t *c;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c = gdk_cairo_create(w-&gt;window);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do_blit(c);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_destroy(c);
<br>}<br><br>int<br>main(int argc, char **argv)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GtkWidget *w, *da;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; create_surface();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gtk_init(&amp;argc, &amp;argv);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; w = gtk_window_new(GTK_WINDOW_TOPLEVEL);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; da = gtk_drawing_area_new();
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gtk_widget_set_size_request(w, WINDOW_WIDTH, WINDOW_HEIGHT);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_signal_connect(da, &quot;expose-event&quot;, G_CALLBACK(paint), NULL);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gtk_container_add(GTK_CONTAINER(w), da);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gtk_widget_show_all(w);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gtk_main();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br>}<br>/*********************** END SIMPLE PROGRAM ***************************/<br><br><br>PATCHES:<br><br>Index: cairo_snippets_gtk.c<br>===================================================================
<br>RCS file: /cvs/cairo/cairo-demo/cairo_snippets/cairo_snippets_gtk.c,v<br>retrieving revision 1.4<br>diff -a -u -r1.4 cairo_snippets_gtk.c<br>--- cairo_snippets_gtk.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 11 Jan 2005 22:38:03 -0000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.4<br>+++ cairo_snippets_gtk.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 11 Aug 2006 01:06:37 -0000
<br>@@ -3,7 +3,6 @@<br>&nbsp; */<br><br>&nbsp;#include &quot;snippets.h&quot;<br>-#include &lt;gtkcairo.h&gt;<br>&nbsp;#include &lt;gtk/gtk.h&gt;<br>&nbsp;#include &lt;stdio.h&gt;<br><br>@@ -13,15 +12,19 @@<br><br>&nbsp;static void<br>&nbsp;paint (GtkWidget *widget,
<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_t&nbsp;&nbsp; *cr,<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *data)<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GdkEvent *event)<br>&nbsp;{<br>+&nbsp;&nbsp;&nbsp; cairo_t *cr;<br>+<br>+&nbsp;&nbsp;&nbsp; cr = gdk_cairo_create(widget-&gt;window);<br>+<br>&nbsp;&nbsp;&nbsp;&nbsp; gint width = widget-&gt;allocation.width

;<br>&nbsp;&nbsp;&nbsp;&nbsp; gint height = widget-&gt;allocation.height;<br><br>&nbsp;&nbsp;&nbsp;&nbsp; cairo_save (cr);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; snippet_do (cr, current_snippet, width, height);<br>&nbsp;&nbsp;&nbsp;&nbsp; cairo_restore (cr);<br>+&nbsp;&nbsp;&nbsp; cairo_destroy(cr);<br>&nbsp;}<br><br>&nbsp;static void
<br>@@ -123,10 +126,10 @@<br>&nbsp;&nbsp;&nbsp;&nbsp; hpaned = gtk_hpaned_new ();<br>&nbsp;&nbsp;&nbsp;&nbsp; vpaned = gtk_vpaned_new ();<br><br>-&nbsp;&nbsp;&nbsp; gtkcairo = gtk_cairo_new ();<br>+&nbsp;&nbsp;&nbsp; gtkcairo = gtk_drawing_area_new ();<br>&nbsp;&nbsp;&nbsp;&nbsp; gtk_widget_set_usize (GTK_WIDGET (gtkcairo), 256, 256);
<br><br>-&nbsp;&nbsp;&nbsp; g_signal_connect (G_OBJECT (gtkcairo), &quot;paint&quot;,<br>+&nbsp;&nbsp;&nbsp; g_signal_connect (G_OBJECT (gtkcairo), &quot;expose-event&quot;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; G_CALLBACK (paint), NULL);<br><br>&nbsp;&nbsp;&nbsp;&nbsp; source_view = create_source_view ();
<br>Index: <a href="http://configure.ac" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">configure.ac</a><br>===================================================================<br>RCS file: /cvs/cairo/cairo-demo/cairo_snippets/configure.ac,v
<br>retrieving revision 1.3<br>
diff -a -u -r1.3 <a href="http://configure.ac" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">configure.ac</a><br>--- <a href="http://configure.ac" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
configure.ac</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 24 Feb 2005 16:21:01 -0000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.3<br>+++ <a href="http://configure.ac" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">configure.ac</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 11 Aug 2006 01:06:37 -0000
<br>@@ -9,7 +9,7 @@<br>&nbsp;AC_STDC_HEADERS<br><br>&nbsp;PKG_CHECK_MODULES(SNIPPETS, libpng libsvg-cairo &gt;= 0.1.2 cairo &gt;= 0.3.0)<br>-PKG_CHECK_MODULES(GTKCAIRO, gtkcairo, enable_gtkcairo=yes, enable_gtkcairo=no)<br>+PKG_CHECK_MODULES(GTKCAIRO, gtk+-
2.0 &gt;= 2.8, enable_gtkcairo=yes, enable_gtkcairo=no)<br><br>&nbsp;AM_CONDITIONAL(BUILD_GTKCAIRO, test x$enable_gtkcairo = xyes)<br><br><br>