# HG changeset patch # User Sebastien Jodogne # Date 1537863479 -7200 # Node ID f4c232bba1eb53aaeb171569f46436e9a8107f8a # Parent 0d8b753317b28e88756579817a38be99d7424606 bgra32 to grayscale conversion diff -r 0d8b753317b2 -r f4c232bba1eb Core/Images/ImageProcessing.cpp --- a/Core/Images/ImageProcessing.cpp Tue Sep 25 07:08:37 2018 +0200 +++ b/Core/Images/ImageProcessing.cpp Tue Sep 25 10:17:59 2018 +0200 @@ -469,6 +469,25 @@ return; } + if (target.GetFormat() == PixelFormat_Grayscale8 && + source.GetFormat() == PixelFormat_BGRA32) + { + for (unsigned int y = 0; y < source.GetHeight(); y++) + { + const uint8_t* p = reinterpret_cast(source.GetConstRow(y)); + uint8_t* q = reinterpret_cast(target.GetRow(y)); + for (unsigned int x = 0; x < source.GetWidth(); x++, q++) + { + *q = static_cast((2126 * static_cast(p[2]) + + 7152 * static_cast(p[1]) + + 0722 * static_cast(p[0])) / 10000); + p += 4; + } + } + + return; + } + if (target.GetFormat() == PixelFormat_RGB24 && source.GetFormat() == PixelFormat_RGBA32) {