diff options
author | richiesams | 2013-07-29 10:59:09 -0500 |
---|---|---|
committer | richiesams | 2013-08-04 13:32:43 -0500 |
commit | f8bc82080a82d7ed198c88d7a839c32e092ede52 (patch) | |
tree | 80473b811aec92c91db8fb006f6386144f86284c /engines | |
parent | 4acdf5b7d51869bfb697e345a9a90f487d8fafc0 (diff) | |
download | scummvm-rg350-f8bc82080a82d7ed198c88d7a839c32e092ede52.tar.gz scummvm-rg350-f8bc82080a82d7ed198c88d7a839c32e092ede52.tar.bz2 scummvm-rg350-f8bc82080a82d7ed198c88d7a839c32e092ede52.zip |
ZVISION: Create function for mixing two RGB<555> colors
Diffstat (limited to 'engines')
-rw-r--r-- | engines/zvision/render_table.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp index d1f8258e02..ca7f9a8030 100644 --- a/engines/zvision/render_table.cpp +++ b/engines/zvision/render_table.cpp @@ -22,6 +22,7 @@ #include "common/scummsys.h" +#include "graphics/colormasks.h" #include "zvision/render_table.h" #include "zvision/point.h" @@ -59,6 +60,27 @@ void RenderTable::setRenderState(RenderState newState) { } } +uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) { + assert(percentColorOne < 1.0f); + + float rOne = float((colorOne & Graphics::ColorMasks<555>::kRedMask) >> Graphics::ColorMasks<555>::kRedShift); + float rTwo = float((colorTwo & Graphics::ColorMasks<555>::kRedMask) >> Graphics::ColorMasks<555>::kRedShift); + float gOne = float((colorOne & Graphics::ColorMasks<555>::kGreenMask) >> Graphics::ColorMasks<555>::kGreenShift); + float gTwo = float((colorTwo & Graphics::ColorMasks<555>::kGreenMask) >> Graphics::ColorMasks<555>::kGreenShift); + float bOne = float((colorOne & Graphics::ColorMasks<555>::kBlueMask) >> Graphics::ColorMasks<555>::kBlueShift); + float bTwo = float((colorTwo & Graphics::ColorMasks<555>::kBlueMask) >> Graphics::ColorMasks<555>::kBlueShift); + + float rFinal = rOne * percentColorOne + rTwo * (1.0f - percentColorOne); + float gFinal = gOne * percentColorOne + gTwo * (1.0f - percentColorOne); + float bFinal = bOne * percentColorOne + bTwo * (1.0f - percentColorOne); + + uint16 returnColor = (byte(rFinal + 0.5f) << Graphics::ColorMasks<555>::kRedShift) | + (byte(gFinal + 0.5f) << Graphics::ColorMasks<555>::kGreenShift) | + (byte(bFinal + 0.5f) << Graphics::ColorMasks<555>::kBlueShift); + + return returnColor; +} + void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 imageWidth, uint32 imageHeight, Common::Rect subRectangle, Common::Rect destRectangle) { bool isTransposed = _renderState == RenderTable::PANORAMA || _renderState == RenderTable::TILT; |