rpav / cl-cairo2

Cairo bindings for Common Lisp

Home Page:https://github.com/rpav/cl-cairo2/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Export format-stride-for-width

kensanata opened this issue · comments

I'm using the following monkey patch in my program:

(in-package :cairo)

(defun format-stride-for-width (format width)
  (cairo_format_stride_for_width (lookup-enum format table-format) width))

(export 'format-stride-for-width)

The reason being is that I'm painting onto a SDL2 surface.

  (let* ((surface (get-window-surface window))
	 (x (* *dimension* *scale*))
	 (y (* 2 x))
	 (line-height x))
    (setf cairo:*context*
	  (cairo:create-context
	   (cairo:create-image-surface-for-data
	    (surface-pixels surface)
	    :argb32
	    (surface-width surface)
	    (surface-height surface)
	    (cairo:format-stride-for-width :argb32 (surface-width surface)))))
   …

The Cairo docs tell me that I need to calculate stride using cairo_format_stride_for_width, which is why I've added it. I think it would make a good addition to surface.lisp and I'd be happy to send a pull request.