summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2014-02-12 13:24:15 +0100
committerPierre Ossman <ossman@cendio.se>2014-07-14 16:00:12 +0200
commit9cbdec67c9973faf950c0eb6ba56f927dfccaf6f (patch)
tree8cf14d57e1854b461e2295a6f4a3cf8f5fe7c844
parent9da47f879e4d913d39cf346702647c802fb452a3 (diff)
downloadtigervnc-9cbdec67c9973faf950c0eb6ba56f927dfccaf6f.tar.gz
tigervnc-9cbdec67c9973faf950c0eb6ba56f927dfccaf6f.zip
Add convenience variant of getImage()
-rw-r--r--common/rfb/PixelBuffer.cxx20
-rw-r--r--common/rfb/PixelBuffer.h5
2 files changed, 25 insertions, 0 deletions
diff --git a/common/rfb/PixelBuffer.cxx b/common/rfb/PixelBuffer.cxx
index ed74a874..3f7f3019 100644
--- a/common/rfb/PixelBuffer.cxx
+++ b/common/rfb/PixelBuffer.cxx
@@ -60,6 +60,26 @@ PixelBuffer::getImage(void* imageBuf, const Rect& r, int outStride) {
}
}
+void PixelBuffer::getImage(const PixelFormat& pf, void* imageBuf,
+ const Rect& r, int stride)
+{
+ const rdr::U8* srcBuffer;
+ int srcStride;
+
+ if (format.equal(pf)) {
+ getImage(imageBuf, r, stride);
+ return;
+ }
+
+ if (stride == 0)
+ stride = r.width();
+
+ srcBuffer = getBuffer(r, &srcStride);
+
+ pf.bufferFromBuffer((U8*)imageBuf, format, srcBuffer, r.width(), r.height(),
+ stride, srcStride);
+}
+
// -=- Modifiable generic pixel buffer class
ModifiablePixelBuffer::ModifiablePixelBuffer(const PixelFormat& pf,
diff --git a/common/rfb/PixelBuffer.h b/common/rfb/PixelBuffer.h
index 7060a014..5bc06c29 100644
--- a/common/rfb/PixelBuffer.h
+++ b/common/rfb/PixelBuffer.h
@@ -72,6 +72,11 @@ namespace rfb {
// 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);
+ // 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);
///////////////////////////////////////////////
// Framebuffer update methods