Skip to content

Commit

Permalink
PEGASUS: Allow getting frames from videos
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Hoops committed Sep 29, 2011
1 parent de5849b commit 8bc2401
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
4 changes: 2 additions & 2 deletions engines/pegasus/neighborhood/neighborhood.cpp
Expand Up @@ -1023,8 +1023,7 @@ void Neighborhood::startTurnPush(const tTurnDirection turnDirection, const TimeV
// will work.
_navMovie.setSegment(0, _navMovie.getDuration());

// TODO
//_pushIn.initFromMovieFrame(_navMovie.getMovie(), newView, kNoMask);
_pushIn.initFromMovieFrame(_navMovie.getMovie(), newView);

_navMovie.hide();

Expand Down Expand Up @@ -1075,6 +1074,7 @@ void Neighborhood::startTurnPush(const tTurnDirection turnDirection, const TimeV
_turnPush.continueFader();

do {
_vm->checkCallBacks();
_vm->refreshDisplay();
_vm->_system->delayMillis(10);
} while (_turnPush.isFading());
Expand Down
29 changes: 29 additions & 0 deletions engines/pegasus/surface.cpp
Expand Up @@ -131,6 +131,22 @@ void Surface::getImageFromPICTStream(Common::SeekableReadStream *stream) {
_bounds = Common::Rect(0, 0, _surface->w, _surface->h);
}

void Surface::getImageFromMovieFrame(Video::SeekableVideoDecoder *video, TimeValue time) {
video->seekToTime(Audio::Timestamp(0, time, 600));
const Graphics::Surface *frame = video->decodeNextFrame();

if (frame) {
if (!_surface)
_surface = new Graphics::Surface();

_surface->copyFrom(*frame);
_ownsSurface = true;
_bounds = Common::Rect(0, 0, _surface->w, _surface->h);
} else {
deallocateSurface();
}
}

void Surface::copyToCurrentPort() const {
copyToCurrentPort(_bounds);
}
Expand Down Expand Up @@ -218,6 +234,11 @@ void Frame::initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool
_transparent = transparent;
}

void Frame::initFromMovieFrame(Video::SeekableVideoDecoder *video, TimeValue time, bool transparent) {
getImageFromMovieFrame(video, time);
_transparent = transparent;
}

void Picture::draw(const Common::Rect &r) {
Common::Rect surfaceBounds;
getSurfaceBounds(surfaceBounds);
Expand Down Expand Up @@ -250,4 +271,12 @@ void Picture::initFromPICTResource(Common::MacResManager *resFork, uint16 id, bo
sizeElement(surfaceBounds.width(), surfaceBounds.height());
}

void Picture::initFromMovieFrame(Video::SeekableVideoDecoder *video, TimeValue time, bool transparent) {
Frame::initFromMovieFrame(video, time, transparent);

Common::Rect surfaceBounds;
getSurfaceBounds(surfaceBounds);
sizeElement(surfaceBounds.width(), surfaceBounds.height());
}

} // End of namespace Pegasus
3 changes: 3 additions & 0 deletions engines/pegasus/surface.h
Expand Up @@ -73,6 +73,7 @@ class Surface {

virtual void getImageFromPICTFile(const Common::String &fileName);
virtual void getImageFromPICTResource(Common::MacResManager *resFork, uint16 id);
virtual void getImageFromMovieFrame(Video::SeekableVideoDecoder *, TimeValue);

protected:
bool _ownsSurface;
Expand Down Expand Up @@ -103,6 +104,7 @@ class Frame : public PixelImage {

virtual void initFromPICTFile(const Common::String &fileName, bool transparent = false);
virtual void initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool transparent = false);
virtual void initFromMovieFrame(Video::SeekableVideoDecoder *, TimeValue, bool transparent = false);
};

class SpriteFrame : public Frame {
Expand All @@ -122,6 +124,7 @@ class Picture : public DisplayElement, public Frame {

virtual void initFromPICTFile(const Common::String &fileName, bool transparent = false);
virtual void initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool transparent = false);
virtual void initFromMovieFrame(Video::SeekableVideoDecoder *, TimeValue, bool transparent = false);

virtual void draw(const Common::Rect &);
};
Expand Down

0 comments on commit 8bc2401

Please sign in to comment.