本文整理汇总了C++中video::VideoDecoder::getPalette方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoDecoder::getPalette方法的具体用法?C++ VideoDecoder::getPalette怎么用?C++ VideoDecoder::getPalette使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类video::VideoDecoder
的用法示例。
在下文中一共展示了VideoDecoder::getPalette方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawNextFrame
bool VideoManager::drawNextFrame(VideoEntryPtr videoEntry) {
Video::VideoDecoder *video = videoEntry->_video;
const Graphics::Surface *frame = video->decodeNextFrame();
if (!frame || !videoEntry->isEnabled()) {
return false;
}
Graphics::Surface *convertedFrame = nullptr;
Graphics::PixelFormat pixelFormat = _vm->_system->getScreenFormat();
if (frame->format != pixelFormat) {
// We don't support downconverting to 8bpp without having
// support in the codec. Set _enableDither if shows up.
if (pixelFormat.bytesPerPixel == 1) {
warning("Cannot convert high color video frame to 8bpp");
return false;
}
// Convert to the current screen format
convertedFrame = frame->convertTo(pixelFormat, video->getPalette());
frame = convertedFrame;
} else if (pixelFormat.bytesPerPixel == 1 && video->hasDirtyPalette()) {
// Set the palette when running in 8bpp mode only
// Don't do this for Myst, which has its own per-stack handling
if (_vm->getGameType() != GType_MYST)
_vm->_system->getPaletteManager()->setPalette(video->getPalette(), 0, 256);
}
// Clip the video to make sure it stays on the screen (Myst does this a few times)
Common::Rect targetRect = Common::Rect(video->getWidth(), video->getHeight());
targetRect.translate(videoEntry->getX(), videoEntry->getY());
Common::Rect frameRect = Common::Rect(video->getWidth(), video->getHeight());
if (targetRect.left < 0) {
frameRect.left -= targetRect.left;
targetRect.left = 0;
}
if (targetRect.top < 0) {
frameRect.top -= targetRect.top;
targetRect.top = 0;
}
if (targetRect.right > _vm->_system->getWidth()) {
frameRect.right -= targetRect.right - _vm->_system->getWidth();
targetRect.right = _vm->_system->getWidth();
}
if (targetRect.bottom > _vm->_system->getHeight()) {
frameRect.bottom -= targetRect.bottom - _vm->_system->getHeight();
targetRect.bottom = _vm->_system->getHeight();
}
_vm->_system->copyRectToScreen(frame->getBasePtr(frameRect.left, frameRect.top), frame->pitch,
targetRect.left, targetRect.top, targetRect.width(), targetRect.height());
// Delete 8bpp conversion surface
if (convertedFrame) {
convertedFrame->free();
delete convertedFrame;
}
// We've drawn something to the screen, make sure we update it
return true;
}
示例2: updateMovies
bool VideoManager::updateMovies() {
bool updateScreen = false;
for (VideoList::iterator it = _videos.begin(); it != _videos.end(); ) {
// Check of the video has reached the end
if ((*it)->endOfVideo()) {
if ((*it)->isLooping()) {
// Seek back if looping
(*it)->seek((*it)->getStart());
} else {
// Done; close and continue on
(*it)->close();
it = _videos.erase(it);
continue;
}
}
Video::VideoDecoder *video = (*it)->_video;
// Ignore paused videos
if (video->isPaused()) {
it++;
continue;
}
// Check if we need to draw a frame
if (video->needsUpdate()) {
const Graphics::Surface *frame = video->decodeNextFrame();
Graphics::Surface *convertedFrame = 0;
if (frame && (*it)->isEnabled()) {
Graphics::PixelFormat pixelFormat = _vm->_system->getScreenFormat();
if (frame->format != pixelFormat) {
// We don't support downconverting to 8bpp without having
// support in the codec. Set _enableDither if shows up.
if (pixelFormat.bytesPerPixel == 1) {
warning("Cannot convert high color video frame to 8bpp");
(*it)->close();
it = _videos.erase(it);
continue;
}
// Convert to the current screen format
convertedFrame = frame->convertTo(pixelFormat, video->getPalette());
frame = convertedFrame;
} else if (pixelFormat.bytesPerPixel == 1 && video->hasDirtyPalette()) {
// Set the palette when running in 8bpp mode only
// Don't do this for Myst, which has its own per-stack handling
if (_vm->getGameType() != GType_MYST)
_vm->_system->getPaletteManager()->setPalette(video->getPalette(), 0, 256);
}
// Clip the width/height to make sure we stay on the screen (Myst does this a few times)
uint16 width = MIN<int32>(video->getWidth(), _vm->_system->getWidth() - (*it)->getX());
uint16 height = MIN<int32>(video->getHeight(), _vm->_system->getHeight() - (*it)->getY());
_vm->_system->copyRectToScreen(frame->getPixels(), frame->pitch, (*it)->getX(), (*it)->getY(), width, height);
// We've drawn something to the screen, make sure we update it
updateScreen = true;
// Delete 8bpp conversion surface
if (convertedFrame) {
convertedFrame->free();
delete convertedFrame;
}
}
}
// Check the video time
_vm->doVideoTimer(*it, false);
// Remember to increase the iterator
it++;
}
// Return true if we need to update the screen
return updateScreen;
}