title: cairo : blurred shapes and text
body: <p>I am drawing some random rectangles via <a href="http://cairographics.org/" rel="nofollow">cairo</a> in its image surface, <strong>scaling and translating</strong> it and displaying the result using </p>
  
  <pre><code>unsigned char* data = cairo_image_surface_get_data(surface);
  </code></pre>
  
  <p>but the rectangles seem blurred:
  <strong>(I could not post the screenshot)</strong></p>
  
  <p>Corners are (probably) not mapped to integer coordinates. The texture containing <code>data</code> is the same size and format with the <code>surface</code> and I have already played with AntiAliasing settings (text display is even more blurry!!). What should I do to map the resulting shapes to integer coordinates and improve quality (without using super-sampling and without dropping scaling-translation)?</p>
  
  <p>Edit: I used the below code (with and without the third line) and it didn't work!:</p>
  
  <pre><code>cairo_save(cr);    
  cairo_identity_matrix(cr);
  cairo_translate(cr, 0.5, 0.5);
  cairo_scale(cr, size.width, size.height);
  cairo_set_antialias(cr, CAIRO_ANTIALIAS_GOOD);
  (make the drawing!!)
  cairo_restore(cr);
  </code></pre>
  
  <p>Edit2: I used the snapping fun. (after all transformations code), but it also did not work:</p>
  
  <pre><code>double szero1 = zero,szero2 = zero, sone1 = one, sone2 = one;
  snapToPixel(cr, &amp;szero1, &amp;szero2);
  snapToPixel(cr, &amp;sone1, &amp;sone2);
  cairo_rectangle (cr, szero1, szero2, sone1, sone2);
  </code></pre>