anchor.diff:        (%surface-mark-dirty-rectangle surface x y width height)
       (%surface-mark-dirty surface)))
   
  -#?(pkg-exists-p "cairo" :atleast-version "1.2")
   (defbinding surface-set-fallback-resolution () nil
     (surface surface)
     (x-pixels-per-inch double-float)
     (y-pixels-per-inch double-float))
   
  +(define-callback stream-write-func status 
  +    ((stream-id pointer-data) (data pointer) (length unsigned-int))
  +  (let ((stream (find-user-data stream-id)))
  +    (typecase stream
  +      (stream
  +       (map-c-vector 'nil #'(lambda (octet) (write-byte octet stream))
  +	data '(unsigned-byte 8) length))
  +      ((or symbol function)
  +       (funcall stream 
  +	(map-c-vector 'vector #'identity data '(unsigned-byte 8) length)))))
  +  :success)
  +
   
   ;; Image Surface
   
   ;; Should data be automatically freed when the surface is GCed?
   (defmethod allocate-foreign ((surface image-surface) 
  -			     &key width height stride format data)
  -  (if (not data)
  -      (%image-surface-create format width height)
  +			     &key filename width height stride format data)
  +  (cond
  +   (filename (%image-surface-create-from-png filename))
  +   ((not data) (%image-surface-create format width height))
  +   (t
       (%image-surface-create-for-data data format width height 
        (or 
         stride
         (let ((element-size (cdr (assoc format '((:argb32 . 4) (:rgb24 . 4) (:a8 . 1) (:a1 1/8))))))
  -	(ceiling (* width element-size)))))))
  -
  -
  -(defbinding %image-surface-create () image-surface
  +	(ceiling (* width element-size))))))))
  +
  +
  +(defbinding %image-surface-create () pointer
     (format surface-format)
     (width int)
     (hegit int))
   
  -(defbinding %image-surface-create-for-data () image-surface
  +(defbinding %image-surface-create-for-data () pointer
     (data pointer)
     (format surface-format)
     (width int)
     (hegit int)
     (stride int))
   
  -
  -
  -;;; PNG Surface
  -
  -(defbinding image-surface-create-from-png (filename) image-surface
  -  ((truename filename) pathname))
  -
  +(defbinding %image-surface-create-from-png () pointer
  +  (filename pathname))
  +
  +(defbinding surface-write-to-png () status
  +  (surface surface)
  +  (filename pathname))
  +
  +
  +;;; PDF Surface
  +
  +(defmethod allocate-foreign ((surface pdf-surface)
  +			     &key filename stream width height)
  +  (cond
  +   ((and filename stream)
  +    (error "Only one of the arguments :filename and :stream may be specified"))
  +   (filename (%pdf-surface-create filename width height))
  +   (stream 
  +    (let* ((stream-id (register-user-data stream))
  +	   (location (%pdf-surface-create-for-stream stream-id width height)))
  +      (%surface-set-user-data location 'stream stream-id)
  +      location))))
  +
  +
  +(defbinding %pdf-surface-create () pointer
  +  (filename pathname)
  +  (width double-float)
  +  (height double-float))
  +
  +(defbinding %pdf-surface-create-for-stream (stream width height) pointer
  +  (stream-write-func callback)
  +  (stream pointer-data)
  +  (width double-float)
  +  (height double-float))
  +
  +(defbinding pdf-surface-set-size () nil
  +  (surface pdf-surface)
  +  (width double-float)
  +  (height double-float))
  +
  +
  +;;; PS Surface
  +
  +(defmethod allocate-foreign ((surface ps-surface) 
  +			     &key filename stream width height)
  +  (cond
  +   ((and filename stream)
  +    (error "Only one of the arguments :filename and :stream may be specified"))
  +   (filename (%ps-surface-create filename width height))
  +   (stream 
  +    (let* ((stream-id (register-user-data stream))
  +	   (location (%ps-surface-create-for-stream stream-id width height)))
  +      (%surface-set-user-data location 'stream stream-id)
  +      location))))
  +
  +(defbinding %ps-surface-create () pointer
  +  (filename pathname)
  +  (width double-float)
  +  (height double-float))
  +
  +(defbinding %ps-surface-create-for-stream (stream width height) pointer
  +  (stream-write-func callback)
  +  (stream pointer-data)
  +  (width double-float)
  +  (height double-float))
  +
  +(defbinding ps-surface-set-size () nil
  +  (surface ps-surface)
  +  (width double-float)
  +  (height double-float))
  +
  +(defbinding ps-surface-dsc-begin-setup () nil
  +  (surface ps-surface))
  +
  +(defbinding ps-surface-dsc-begin-page-setup () nil
  +  (surface ps-surface))
  +
  +(defbinding ps-surface-dsc-comment () nil
  +  (surface ps-surface)
  +  (comment string))
  +
  +
  +;;; SVG Surface
  +
  +(defmethod allocate-foreign ((surface svg-surface) 
  +			     &key filename stream width height)
  +  (cond
  +   ((and filename stream)
  +    (error "Only one of the arguments :filename and :stream may be specified"))
  +   (filename (%svg-surface-create filename width height))
  +   (stream 
  +    (let* ((stream-id (register-user-data stream))
  +	   (location (%svg-surface-create-for-stream stream-id width height)))
  +      (%surface-set-user-data location 'stream stream-id)
  +      location))))
  +
  +(defbinding %svg-surface-create () pointer
  +  (filename pathname)
  +  (width double-float)
  +  (height double-float))
  +
  +(defbinding %svg-surface-create-for-stream (stream width height) pointer
  +  (stream-write-func callback)
  +  (stream pointer-data)
  +  (width double-float)
  +  (height double-float))
  +
  +(defbinding svg-surface-restrict-to-version () nil
  +  (surface svg-surface)
  +  (version svg-version))
   
   
   
  
positive.code:   (xy double-float) (yy double-float) 
    (x0 double-float) (y0 double-float))
  
  (defbinding matrix-init-identity () nil
    (matrix matrix :in/return))
  
  (defbinding matrix-init-translate () nil
  
negative.code:       (multiple-value-call #'scale cr (device-to-user-distance cr 1.0))
      (multiple-value-bind (x y) 
  	(multiple-value-call #'user-to-device cr (get-current-point cr))
  ;      (identity-matrix cr)
        (setf (matrix cr) (matrix-init-identity))
        (translate cr x y))))
  
  (defbinding rotate () nil
  