Hi all,<br><br>Thanks for all inputs.<br>I remember I tested the byte 
ordering manually so in this case that was not the problem (even it was 
not platform independent code I agree).<br>Here the issue seems to be the problem raised by behdad in Carlos' thread : <a href="http://lists.freedesktop.org/archives/cairo/2012-July/023298.html" target="_blank">http://lists.freedesktop.org/archives/cairo/2012-July/023298.html</a><br>

<br><pre> * @CAIRO_FORMAT_ARGB32: each pixel is a 32-bit quantity, with
 *   alpha in the upper 8 bits, then red, then green, then blue.
 *   The 32-bit quantities are stored native-endian. <b>Pre-multiplied
 *   alpha is used. (That is, 50% transparent red is 0x80800000,
 *   not 0x80ff0000.) (Since 1.0)</b></pre><br>So I had to level the r, g, and b values to "alpha" maximum.<br>In other words, I understood that r or g or b should never be greater than the matching opacity value.<br>

<br>For anyone interested, please find below how I interpreted it (for now).<br>Thanks,<br><br>Steve<br><br>void setColor(unsigned char* pixel, unsigned int color, unsigned char opacity = 0xFF)<br>{<br>  unsigned char r = (color >> 16) & 0xFF;<br>

  unsigned char g = (color >> 8) & 0xFF;<br>  unsigned char b = (color) & 0xFF;<br><br>  r = r*opacity/255;<br>  g = g*opacity/255;<br>  b = b*opacity/255;<br>  <br>  *((unsigned int*) pixel) = opacity << 24 | r << 16 | g << 8 | b;<div class="">
<div id=":32q" class="" tabindex="0"><img class="" src="https://mail.google.com/mail/u/1/images/cleardot.gif">}</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2012/11/6 Steve Moreau <span dir="ltr"><<a href="mailto:moreau.steve@free.fr" target="_blank">moreau.steve@free.fr</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im HOEnZb">Thank you guys,<br><br>I will try and let you know when it works.<br>Regards,<br><br>Steve</div>
<div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">2012/11/5 Bill Spitzak <span dir="ltr"><<a href="mailto:spitzak@gmail.com" target="_blank">spitzak@gmail.com</a>></span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Cairo wants pre-multiplied data for the OVER composite. This likely means that the green value should depend on y just like the alpha value does. Ie set the green to (y < 50 ? 0 : 50 * (y - 50)/height)<br>


<br>
Also I recommend filling in the buffer as 32-bit words, rather than bytes. This is faster and will make the it work on a big-endian machine.<br>
<br>
unsigned char* buf = (unsigned char*)malloc(4*width*height);<br>
  cairo_surface_t* dataSurface = cairo_image_surface_create_<u></u>for_data (buf, CAIRO_FORMAT_ARGB32, width, height, rowLen);<br>
  for (y=0; y<height; y++)<br>
  {<br>
    for (x=0; x<width; x++)<br>
    {<br>
      //setColor(&buf[y*rowLen+x*4], 0x00FF00, y*255.0/3/height);<br>
      buf[y*rowLen+x*4+0] = 0;<br>
      buf[y*rowLen+x*4+1] = 50;<br>
      buf[y*rowLen+x*4+2] = 0;<br>
      buf[y*rowLen+x*4+3] = (y < 50 ? 0 : (y-50)*255.0/height);<br>
    }<br>
  }<br>
<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>