aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorrichiesams2013-08-14 19:42:56 -0500
committerrichiesams2013-08-15 14:31:21 -0500
commit7e8e9bf3d1e718758298b8fb5ccc6a0f296d5b9c (patch)
treed1626c2de2cc82d65561af506f10f5f4f5590419 /graphics
parent999de6d400be8374a6834a81bb8b8f4da4a1756c (diff)
downloadscummvm-rg350-7e8e9bf3d1e718758298b8fb5ccc6a0f296d5b9c.tar.gz
scummvm-rg350-7e8e9bf3d1e718758298b8fb5ccc6a0f296d5b9c.tar.bz2
scummvm-rg350-7e8e9bf3d1e718758298b8fb5ccc6a0f296d5b9c.zip
GRAPHICS: Create copyRectToSurface member function
Diffstat (limited to 'graphics')
-rw-r--r--graphics/surface.cpp18
-rw-r--r--graphics/surface.h13
2 files changed, 31 insertions, 0 deletions
diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index 929157203e..d808121c87 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -133,6 +133,24 @@ const Surface Surface::getSubArea(const Common::Rect &area) const {
return subSurface;
}
+void Surface::copyRectToSurface(const void *buffer, int pitch, int x, int y, int width, int height) {
+ assert(buffer);
+
+ assert(x >= 0 && x < w);
+ assert(y >= 0 && y < h);
+ assert(height > 0 && y + height <= h);
+ assert(width > 0 && x + width <= w);
+
+ // Copy buffer data to internal buffer
+ const byte *src = (const byte *)buffer;
+ byte *dst = (byte *)getBasePtr(x, y);
+ for (int i = 0; i < height; i++) {
+ memcpy(dst, src, width * format.bytesPerPixel);
+ src += pitch;
+ dst += this->pitch;
+ }
+}
+
void Surface::hLine(int x, int y, int x2, uint32 color) {
// Clipping
if (y < 0 || y >= h)
diff --git a/graphics/surface.h b/graphics/surface.h
index b08d4a5cb7..ad52ed8238 100644
--- a/graphics/surface.h
+++ b/graphics/surface.h
@@ -209,6 +209,19 @@ public:
const Surface getSubArea(const Common::Rect &area) const;
/**
+ * Copies a bitmap to the Surface internal buffer. The pixel format
+ * of buffer must match the pixel format of the Surface.
+ *
+ * @param buffer The buffer containing the graphics data source
+ * @param pitch The pitch of the buffer (number of bytes in a scanline)
+ * @param x The x coordinate of the destination rectangle
+ * @param y The y coordinate of the destination rectangle
+ * @param width The width of the destination rectangle
+ * @param height The height of the destination rectangle
+ */
+ void copyRectToSurface(const void *buffer, int pitch, int x, int y, int width, int height);
+
+ /**
* Convert the data to another pixel format.
*
* This works in-place. This means it will not create an additional buffer