<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>bitsnap — Paolo Amoroso&#39;s Journal</title>
    <link>https://journal.paoloamoroso.com/tag:bitsnap</link>
    <description>Tech projects, hobby programming, and geeky thoughts of Paolo Amoroso</description>
    <pubDate>Mon, 16 Nov 2026 17:42:55 +0000</pubDate>
    <image>
      <url>https://i.snap.as/68i8povn.jpg</url>
      <title>bitsnap — Paolo Amoroso&#39;s Journal</title>
      <link>https://journal.paoloamoroso.com/tag:bitsnap</link>
    </image>
    <item>
      <title>Bitsnap, a screenshot capture tool for Medley Interlisp</title>
      <link>https://journal.paoloamoroso.com/bitsnap-a-screenshot-capture-tool-for-medley-interlisp?pk_campaign=rss-feed</link>
      <description>I wrote Bitsnap, a tool in Interlisp for capturing screenshots on the Medley environment. It can capture and optionally save to a file th...</description>
      <content:encoded><![CDATA[<p>I wrote <a href="https://github.com/pamoroso/bitsnap">Bitsnap</a>, a tool in Interlisp for capturing screenshots on the <a href="https://interlisp.org">Medley</a> environment. It can capture and optionally save to a file the full screen, a window with or without title bar and borders, or an arbitrary area.</p>

<p>This project helped me learn the internals of Medley, such as extending the background menu, and produced a tool I wanted. For example, with Bitsnap I can capture some areas like specific windows without manually framing them; or the full screen of Medley excluding the title bar and borders of the operating systems that hosts Medley, Linux in my case.</p>

<p>Medley can natively capture various portions of the screen. These facilities produce 1-bit images as instances of <code>BITMAP</code>, an image data structure Medley uses for everything from bit patterns, to icons, to actual images. Some Lisp functions manipulate bitmaps.</p>

<p>Bitsnap glues together these facilities and packages them in an interactive interface accessible as a submenu of the background menu as well as a programmatic interface, the Interlisp function <a href="https://github.com/pamoroso/bitsnap/blob/2f482d4d2179ae2b9e0df73574a76a76b9ec3b65/BITSNAP#L82"><code>SNAP</code></a>.</p>

<p>To provide feedback after a capture Bitsnap displays in a window the area just captured, as shown here along with the Bitsnap menu.</p>

<p><a href="https://i.snap.as/94zFyIEa.png"><img src="https://i.snap.as/94zFyIEa.png" alt="A bitmap captured with the Bitsnap screenshot tool and its menu on Medley Interlisp."/></a></p>

<p>The tool works by copying to a new bitmap the system bitmap that holds the designated area of the screen. Which is straighforward as there are Interlisp functions for accessing the source bitmaps. These functions return a <code>BITMAP</code> and capture:</p>
<ul><li><code>SCREENBITMAP</code>: the full screen</li>
<li><code>WINDOW.BITMAP</code>: a window including the title bar and border</li>
<li><code>BITMAPCOPY</code>: the interior of a window with no title bar and border</li>
<li><code>SNAPW</code>: an arbitrary area</li></ul>

<p>The slightly more involved part is bringing captured bitmaps out of Medley in a format today&#39;s systems and tools understand. Some Interlisp functions can save a <code>BITMAP</code> to disk in text and binary encodings, none of which are modern standards.</p>

<p>The only Medley tool to export to a modern — or less ancient — format less bound to Lisp is the xerox-to-xbm module which converts a <code>BITMAP</code> to the Unix <a href="https://en.wikipedia.org/wiki/X_BitMap">XBM</a> (X BitMap) format. However, xerox-to-xbm can&#39;t process large bitmaps.</p>

<p>To work around the issue I wrote the function <a href="https://github.com/pamoroso/bitsnap/blob/2f482d4d2179ae2b9e0df73574a76a76b9ec3b65/BITSNAP#L47"><code>BMTOPBM</code></a> that saves a <code>BITMAP</code> to a file in a slightly more modern and popular format, <a href="https://en.wikipedia.org/wiki/Netpbm#PBM_example">PBM</a> (Portable BitMap). I can&#39;t think of anything simpler and, indeed, it took me just half a dozen minutes to write the function. Linux and other modern operating systems can natively display PBM files and <a href="https://en.wikipedia.org/wiki/Netpbm">Netpbm</a> converts PBM to PNG and other widely used standards. For example, this Netpbm pipeline converts to PNG:</p>

<pre><code>$ pbmtopnm screenshot.pbm | pnmtopng &gt; screenshot.png
</code></pre>

<p><code>BMTOPBM</code> can handle bitmaps of any size but its simple algorithm is inefficient. However, on <a href="https://journal.paoloamoroso.com/system76-merkaat-with-linux-mint-first-impressions">my PC</a> the function takes about 5 seconds to save a 1920x1080 bitmap, which is the worst case as this is the maximum screen size Medley allows. Good enough for the time being.</p>

<p>Bitsnap does pretty much all I want and doesn&#39;t need major new features. Still, I may optimize <code>BMTOPBM</code> or save directly to PNG.</p>

<p><a href="https://journal.paoloamoroso.com/tag:Bitsnap" class="hashtag"><span>#</span><span class="p-category">Bitsnap</span></a> <a href="https://journal.paoloamoroso.com/tag:Interlisp" class="hashtag"><span>#</span><span class="p-category">Interlisp</span></a> <a href="https://journal.paoloamoroso.com/tag:Lisp" class="hashtag"><span>#</span><span class="p-category">Lisp</span></a></p>

<p><a href="https://remark.as/p/journal.paoloamoroso.com/bitsnap-a-screenshot-capture-tool-for-medley-interlisp">Discuss...</a>
<a href="mailto:info@paoloamoroso.com?subject=Reply%20to%20Paolo%20Amoroso%27s%20Journal">Email</a> | Reply <a href="/@/amoroso@oldbytes.space" class="u-url mention">@<span>amoroso@oldbytes.space</span></a></p>


]]></content:encoded>
      <guid>https://journal.paoloamoroso.com/bitsnap-a-screenshot-capture-tool-for-medley-interlisp</guid>
      <pubDate>Thu, 06 Mar 2025 09:37:50 +0000</pubDate>
    </item>
  </channel>
</rss>