And I was indeed able to reproduce the png display bug with ImageMagick. I'll try to look in to it.
And regarding cairo, from a top level view it is quite simple. It receives a memory buffer and draws pixels in the buffer. The memory buffer may be either a "normal" memory area, or together with gdk an GdkWindow. Its painting model is PostScript (or svg) like, e.g. moveto, lineto, curveto, stroke, fill, and draw glyphs. It is simpler than than the X11 drawing model as there are e.g. no XOR modes nor 8-bit index modes, etc. The rest is details. :-)