From 7e8e9bf3d1e718758298b8fb5ccc6a0f296d5b9c Mon Sep 17 00:00:00 2001 From: richiesams Date: Wed, 14 Aug 2013 19:42:56 -0500 Subject: GRAPHICS: Create copyRectToSurface member function --- graphics/surface.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'graphics/surface.cpp') 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) -- cgit v1.2.3