diff options
Diffstat (limited to 'engines/sword2')
-rw-r--r-- | engines/sword2/animation.cpp | 35 | ||||
-rw-r--r-- | engines/sword2/animation.h | 1 |
2 files changed, 33 insertions, 3 deletions
diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp index 5eab7f5645..10895b2ec1 100644 --- a/engines/sword2/animation.cpp +++ b/engines/sword2/animation.cpp @@ -51,6 +51,9 @@ MoviePlayer::MoviePlayer(Sword2Engine *vm, Audio::Mixer *snd, OSystem *system, A _bgSoundStream = NULL; _decoderType = decoderType; _decoder = decoder; + + _white = 255; + _black = 0; } MoviePlayer:: ~MoviePlayer() { @@ -280,9 +283,35 @@ bool MoviePlayer::playVideo() { if (frame) _vm->_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h); - if (_decoder->hasDirtyPalette()) + if (_decoder->hasDirtyPalette()) { _decoder->setSystemPalette(); + uint32 maxWeight = 0; + uint32 minWeight = 0xFFFFFFFF; + uint32 weight; + byte r, g, b; + + byte *palette = _decoder->getPalette(); + + for (int i = 0; i < 256; i++) { + r = *palette++; + g = *palette++; + b = *palette++; + + weight = 3 * r * r + 6 * g * g + 2 * b * b; + + if (weight >= maxWeight) { + maxWeight = weight; + _white = i; + } + + if (weight <= minWeight) { + minWeight = weight; + _black = i; + } + } + } + Graphics::Surface *screen = _vm->_system->lockScreen(); performPostProcessing((byte *)screen->pixels); _vm->_system->unlockScreen(); @@ -301,11 +330,11 @@ bool MoviePlayer::playVideo() { } byte MoviePlayer::findBlackPalIndex() { - return 0; + return _black; } byte MoviePlayer::findWhitePalIndex() { - return 0xff; + return _white; } DXADecoderWithSound::DXADecoderWithSound(Audio::Mixer *mixer, Audio::SoundHandle *bgSoundHandle) diff --git a/engines/sword2/animation.h b/engines/sword2/animation.h index bbf83e264c..ee32b1d5f2 100644 --- a/engines/sword2/animation.h +++ b/engines/sword2/animation.h @@ -87,6 +87,7 @@ protected: uint32 _currentMovieText; byte *_textSurface; int _textX, _textY; + byte _white, _black; DecoderType _decoderType; Graphics::VideoDecoder *_decoder; |