[Scummvm-cvs-logs] SF.net SVN: scummvm:[51893] scummvm/trunk/engines/gob
drmccoy at users.sourceforge.net
drmccoy at users.sourceforge.net
Sun Aug 8 02:54:25 CEST 2010
Revision: 51893
http://scummvm.svn.sourceforge.net/scummvm/?rev=51893&view=rev
Author: drmccoy
Date: 2010-08-08 00:54:24 +0000 (Sun, 08 Aug 2010)
Log Message:
-----------
GOB: Add copyFrame
Modified Paths:
--------------
scummvm/trunk/engines/gob/videoplayer.cpp
scummvm/trunk/engines/gob/videoplayer.h
Modified: scummvm/trunk/engines/gob/videoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/videoplayer.cpp 2010-08-08 00:53:55 UTC (rev 51892)
+++ scummvm/trunk/engines/gob/videoplayer.cpp 2010-08-08 00:54:24 UTC (rev 51893)
@@ -513,6 +513,66 @@
}
}
+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;
Modified: scummvm/trunk/engines/gob/videoplayer.h
===================================================================
--- scummvm/trunk/engines/gob/videoplayer.h 2010-08-08 00:53:55 UTC (rev 51892)
+++ scummvm/trunk/engines/gob/videoplayer.h 2010-08-08 00:54:24 UTC (rev 51893)
@@ -124,6 +124,9 @@
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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list