diff options
author | Sven Hesse | 2010-08-08 00:54:24 +0000 |
---|---|---|
committer | Sven Hesse | 2010-08-08 00:54:24 +0000 |
commit | 424e802bb92119ce9a8f95b2399a23d911d061e7 (patch) | |
tree | 2e62e86fbfbdd0a35562665e86be78f2a49089b1 /engines | |
parent | 3c5e02900f6397add6365bea819987bf9d6e89e6 (diff) | |
download | scummvm-rg350-424e802bb92119ce9a8f95b2399a23d911d061e7.tar.gz scummvm-rg350-424e802bb92119ce9a8f95b2399a23d911d061e7.tar.bz2 scummvm-rg350-424e802bb92119ce9a8f95b2399a23d911d061e7.zip |
GOB: Add copyFrame
svn-id: r51893
Diffstat (limited to 'engines')
-rw-r--r-- | engines/gob/videoplayer.cpp | 60 | ||||
-rw-r--r-- | engines/gob/videoplayer.h | 3 |
2 files changed, 63 insertions, 0 deletions
diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp index a2450e1847..1fe05dfbf0 100644 --- a/engines/gob/videoplayer.cpp +++ b/engines/gob/videoplayer.cpp @@ -513,6 +513,66 @@ void VideoPlayer::writeVideoInfo(const Common::String &file, int16 varX, int16 v } } +bool VideoPlayer::copyFrame(int slot, byte *dest, + uint16 left, uint16 top, uint16 width, uint16 height, + uint16 x, uint16 y, uint16 pitch, int16 transp) const { + + const Video *video = getVideoBySlot(slot); + if (!video) + return false; + + const Graphics::Surface *surface = video->decoder->getSurface(); + if (!surface) + return false; + + int32 w = MIN<int32>(width , surface->w); + int32 h = MIN<int32>(height, surface->h); + + const byte *src = (byte*)surface->pixels + (top * surface->pitch) + left; + byte *dst = dest + (y * pitch) + x; + + if (transp < 0) { + // No transparency + + if ((x == 0) && (left == 0) && (pitch == surface->pitch) && (width == surface->w)) { + // Dimensions fit, we can copy everything at once + + memcpy(dst, src, w * h); + return true; + } + + // Copy row-by-row + + while (h-- > 0) { + const byte *srcRow = src; + byte *dstRow = dst; + + memcpy(dst, src, w); + + srcRow += surface->pitch; + dstRow += pitch; + } + + return true; + } + + // Copy pixel-by-pixel + + while (h-- > 0) { + const byte *srcRow = src; + byte *dstRow = dst; + + for (int32 i = 0; i < w; i++, srcRow++, dstRow++) + if (*srcRow != transp) + *dstRow = *srcRow; + + srcRow += surface->pitch; + dstRow += pitch; + } + + return true; +} + const VideoPlayer::Video *VideoPlayer::getVideoBySlot(int slot) const { if ((slot < 0) || (slot >= kVideoSlotCount)) return 0; diff --git a/engines/gob/videoplayer.h b/engines/gob/videoplayer.h index 6f9d927739..2e7e3f396a 100644 --- a/engines/gob/videoplayer.h +++ b/engines/gob/videoplayer.h @@ -124,6 +124,9 @@ public: void writeVideoInfo(const Common::String &file, int16 varX, int16 varY, int16 varFrames, int16 varWidth, int16 varHeight); + bool copyFrame(int slot, byte *dest, + uint16 left, uint16 top, uint16 width, uint16 height, + uint16 x, uint16 y, uint16 pitch, int16 transp = -1) const; // Obsolete, to be deleted |