# HG changeset patch # User Sebastien Jodogne # Date 1521719600 -3600 # Node ID 3d65adee289a843f454444c0d547c1a31d6b5ca2 # Parent cd7b854dbc05022d3899b9a45513c19f2ad903be int16_t to rgba32 conversion diff -r cd7b854dbc05 -r 3d65adee289a Core/Images/ImageProcessing.cpp --- a/Core/Images/ImageProcessing.cpp Tue Mar 20 13:26:00 2018 +0100 +++ b/Core/Images/ImageProcessing.cpp Thu Mar 22 12:53:20 2018 +0100 @@ -594,6 +594,41 @@ } if (target.GetFormat() == PixelFormat_BGRA32 && + source.GetFormat() == PixelFormat_SignedGrayscale16) + { + for (unsigned int y = 0; y < source.GetHeight(); y++) + { + const int16_t* p = reinterpret_cast(source.GetConstRow(y)); + uint8_t* q = reinterpret_cast(target.GetRow(y)); + for (unsigned int x = 0; x < source.GetWidth(); x++) + { + uint8_t value; + if (*p < 0) + { + value = 0; + } + else if (*p > 255) + { + value = 255; + } + else + { + value = static_cast(*p); + } + + q[0] = value; + q[1] = value; + q[2] = value; + q[3] = 255; + p += 1; + q += 4; + } + } + + return; + } + + if (target.GetFormat() == PixelFormat_BGRA32 && source.GetFormat() == PixelFormat_RGB24) { for (unsigned int y = 0; y < source.GetHeight(); y++)