Lisp HUG Maillist Archive

Drawing to an offscreen bitmap

I’ve got a problem using an offscreen bitmap which I hope someone can help with.

I’m creating an image file by drawing to an offscreen bitmap, and then saving it to a file:

(defun draw-test ()
  (let* ((width 100)
         (height 50)
         (port (make-instance 'capi:pinboard-layout))
         (win (capi:display (make-instance 'capi:interface :display-state :hidden :layout port))))
    (gp:with-pixmap-graphics-port (pport port width height)
      (gp:draw-line pport 0 0 99 49)
      (let ((image (gp:make-image-from-port pport)))
        (gp:externalize-and-write-image pport image "/Users/david/Documents/my-test.bmp" :if-exists :supersede)
        (gp:free-image pport image)))
    (capi:destroy win)))

However, when I run this on a Retina Macbook Pro it creates an image of double the size, 200 x 100.

What’s the correct way to get this to work properly? I don’t want to have to scale the image down when I’ve created it, nor do I want to have to halve all my drawing coordinates to get the right result.

Thanks,
David

+------------------------------------------------------------+
David Johnson-Davies, Human-Computer Interface Ltd
17 Signet Court, Swanns Road, Cambridge, CB5 8LA, England.

Tel: +44 1223 314934, Fax: +44 1223 462562
Email: david@interface.co.uk, Web: http://www.interface.co.uk/
+------------------------------------------------------------+


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: Drawing to an offscreen bitmap

Hi David,

Have you tried to use a output-pane as a port (instead of a window)?
I am thinking about the code example at the end of
 http://www.lispworks.com/documentation/lw70/CAPI-M/html/capi-m-855.htm#96750


Best,
Cam


> On 16 Feb 2016, at 17:05, David Johnson-Davies <david@interface.co.uk> wrote:
> 
> 
> I’ve got a problem using an offscreen bitmap which I hope someone can help with.
> 
> I’m creating an image file by drawing to an offscreen bitmap, and then saving it to a file:
> 
> (defun draw-test ()
>  (let* ((width 100)
>         (height 50)
>         (port (make-instance 'capi:pinboard-layout))
>         (win (capi:display (make-instance 'capi:interface :display-state :hidden :layout port))))
>    (gp:with-pixmap-graphics-port (pport port width height)
>      (gp:draw-line pport 0 0 99 49)
>      (let ((image (gp:make-image-from-port pport)))
>        (gp:externalize-and-write-image pport image "/Users/david/Documents/my-test.bmp" :if-exists :supersede)
>        (gp:free-image pport image)))
>    (capi:destroy win)))
> 
> However, when I run this on a Retina Macbook Pro it creates an image of double the size, 200 x 100.
> 
> What’s the correct way to get this to work properly? I don’t want to have to scale the image down when I’ve created it, nor do I want to have to halve all my drawing coordinates to get the right result.
> 
> Thanks,
> David
> 
> +------------------------------------------------------------+
> David Johnson-Davies, Human-Computer Interface Ltd
> 17 Signet Court, Swanns Road, Cambridge, CB5 8LA, England.
> 
> Tel: +44 1223 314934, Fax: +44 1223 462562
> Email: david@interface.co.uk, Web: http://www.interface.co.uk/
> +------------------------------------------------------------+
> 
> 
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> lisp-hug@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html
> 


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Updated at: 2020-12-10 08:32 UTC