Allow PixelBuffers to be const
diff --git a/common/rfb/Cursor.cxx b/common/rfb/Cursor.cxx
index 62b767f..8ef8b17 100644
--- a/common/rfb/Cursor.cxx
+++ b/common/rfb/Cursor.cxx
@@ -82,7 +82,7 @@
   mask.buf = outlined.mask.buf; outlined.mask.buf = 0;
 }
 
-rdr::U8* Cursor::getBitmap(Pixel* pix0, Pixel* pix1)
+rdr::U8* Cursor::getBitmap(Pixel* pix0, Pixel* pix1) const
 {
   bool gotPix0 = false;
   bool gotPix1 = false;
@@ -182,7 +182,7 @@
 {
 }
 
-const rdr::U8* RenderedCursor::getBuffer(const Rect& _r, int* stride)
+const rdr::U8* RenderedCursor::getBuffer(const Rect& _r, int* stride) const
 {
   Rect r;
 
diff --git a/common/rfb/Cursor.h b/common/rfb/Cursor.h
index 5d4623d..560e4d8 100644
--- a/common/rfb/Cursor.h
+++ b/common/rfb/Cursor.h
@@ -34,7 +34,7 @@
     rdr::U8Array mask;
     Point hotspot;
 
-    int maskLen() { return (width() + 7) / 8 * height(); }
+    int maskLen() const { return (width() + 7) / 8 * height(); }
 
     // setSize() resizes the cursor.  The contents of the data and mask are
     // undefined after this call.
@@ -46,7 +46,7 @@
     // getBitmap() tests whether the cursor is monochrome, and if so returns a
     // bitmap together with background and foreground colours.  The size and
     // layout of the bitmap are the same as the mask.
-    rdr::U8* getBitmap(Pixel* pix0, Pixel* pix1);
+    rdr::U8* getBitmap(Pixel* pix0, Pixel* pix1) const;
 
     // crop() crops the cursor down to the smallest possible size, based on the
     // mask.
@@ -59,7 +59,7 @@
 
     Rect getEffectiveRect() const { return buffer.getRect(offset); }
 
-    virtual const rdr::U8* getBuffer(const Rect& r, int* stride);
+    virtual const rdr::U8* getBuffer(const Rect& r, int* stride) const;
 
     void update(PixelBuffer* framebuffer, Cursor* cursor, const Point& pos);
 
diff --git a/common/rfb/PixelBuffer.cxx b/common/rfb/PixelBuffer.cxx
index 3f7f301..b1359c2 100644
--- a/common/rfb/PixelBuffer.cxx
+++ b/common/rfb/PixelBuffer.cxx
@@ -42,7 +42,7 @@
 
 
 void
-PixelBuffer::getImage(void* imageBuf, const Rect& r, int outStride) {
+PixelBuffer::getImage(void* imageBuf, const Rect& r, int outStride) const {
   int inStride;
   const U8* data = getBuffer(r, &inStride);
   // We assume that the specified rectangle is pre-clipped to the buffer
@@ -61,7 +61,7 @@
 }
 
 void PixelBuffer::getImage(const PixelFormat& pf, void* imageBuf,
-                           const Rect& r, int stride)
+                           const Rect& r, int stride) const
 {
   const rdr::U8* srcBuffer;
   int srcStride;
@@ -332,6 +332,12 @@
 {
 }
 
+const rdr::U8* FullFramePixelBuffer::getBuffer(const Rect& r, int* stride_) const
+{
+  *stride_ = stride;
+  return &data[(r.tl.x + (r.tl.y * stride)) * format.bpp/8];
+}
+
 // -=- Managed pixel buffer class
 // Automatically allocates enough space for the specified format & area
 
diff --git a/common/rfb/PixelBuffer.h b/common/rfb/PixelBuffer.h
index 5bc06c2..b0db6eb 100644
--- a/common/rfb/PixelBuffer.h
+++ b/common/rfb/PixelBuffer.h
@@ -65,18 +65,18 @@
     // Get a pointer into the buffer
     //   The pointer is to the top-left pixel of the specified Rect.
     //   The buffer stride (in pixels) is returned.
-    virtual const rdr::U8* getBuffer(const Rect& r, int* stride) = 0;
+    virtual const rdr::U8* getBuffer(const Rect& r, int* stride) const = 0;
 
     // Get pixel data for a given part of the buffer
     //   Data is copied into the supplied buffer, with the specified
     //   stride. Try to avoid using this though as getBuffer() will in
     //   most cases avoid the extra memory copy.
-    void getImage(void* imageBuf, const Rect& r, int stride=0);
+    void getImage(void* imageBuf, const Rect& r, int stride=0) const;
     // Get pixel data in a given format
     //   Works just the same as getImage(), but guaranteed to be in a
     //   specific format.
     void getImage(const PixelFormat& pf, void* imageBuf,
-                  const Rect& r, int stride=0);
+                  const Rect& r, int stride=0) const;
 
     ///////////////////////////////////////////////
     // Framebuffer update methods
@@ -114,11 +114,6 @@
     //   getBufferRW().
     virtual void commitBufferRW(const Rect& r) = 0;
 
-    // Default trivial handling of read-only access
-    virtual const rdr::U8* getBuffer(const Rect& r, int* stride) {
-      return getBufferRW(r, stride);
-    }
-
     ///////////////////////////////////////////////
     // Basic rendering operations
     // These operations DO NOT clip to the pixelbuffer area, or trap overruns.
@@ -162,6 +157,7 @@
     virtual ~FullFramePixelBuffer();
 
   public:
+    virtual const rdr::U8* getBuffer(const Rect& r, int* stride) const;
     virtual rdr::U8* getBufferRW(const Rect& r, int* stride);
     virtual void commitBufferRW(const Rect& r);