diff options
author | richiesams | 2013-08-14 19:42:56 -0500 |
---|---|---|
committer | richiesams | 2013-08-15 14:31:21 -0500 |
commit | 7e8e9bf3d1e718758298b8fb5ccc6a0f296d5b9c (patch) | |
tree | d1626c2de2cc82d65561af506f10f5f4f5590419 /graphics/surface.cpp | |
parent | 999de6d400be8374a6834a81bb8b8f4da4a1756c (diff) | |
download | scummvm-rg350-7e8e9bf3d1e718758298b8fb5ccc6a0f296d5b9c.tar.gz scummvm-rg350-7e8e9bf3d1e718758298b8fb5ccc6a0f296d5b9c.tar.bz2 scummvm-rg350-7e8e9bf3d1e718758298b8fb5ccc6a0f296d5b9c.zip |
GRAPHICS: Create copyRectToSurface member function
Diffstat (limited to 'graphics/surface.cpp')
-rw-r--r-- | graphics/surface.cpp | 18 |
1 files changed, 18 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) |