Mercurial > hg > orthanc-webviewer
diff Orthanc/Core/Images/ImageProcessing.cpp @ 162:f17ecfffdc75
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 10 Jul 2017 11:51:20 +0200 |
parents | 5dc54316d68b |
children | 330ecfd96aec |
line wrap: on
line diff
--- a/Orthanc/Core/Images/ImageProcessing.cpp Thu Jun 15 17:43:34 2017 +0200 +++ b/Orthanc/Core/Images/ImageProcessing.cpp Mon Jul 10 11:51:20 2017 +0200 @@ -458,6 +458,26 @@ return; } + if (target.GetFormat() == PixelFormat_RGB24 && + source.GetFormat() == PixelFormat_BGRA32) + { + for (unsigned int y = 0; y < source.GetHeight(); y++) + { + const uint8_t* p = reinterpret_cast<const uint8_t*>(source.GetConstRow(y)); + uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y)); + for (unsigned int x = 0; x < source.GetWidth(); x++) + { + q[0] = p[2]; + q[1] = p[1]; + q[2] = p[0]; + p += 4; + q += 3; + } + } + + return; + } + if (target.GetFormat() == PixelFormat_RGBA32 && source.GetFormat() == PixelFormat_RGB24) { @@ -752,4 +772,29 @@ throw OrthancException(ErrorCode_NotImplemented); } } + + + void ImageProcessing::Invert(ImageAccessor& image) + { + switch (image.GetFormat()) + { + case PixelFormat_Grayscale8: + { + for (unsigned int y = 0; y < image.GetHeight(); y++) + { + uint8_t* p = reinterpret_cast<uint8_t*>(image.GetRow(y)); + + for (unsigned int x = 0; x < image.GetWidth(); x++, p++) + { + *p = 255 - (*p); + } + } + + return; + } + + default: + throw OrthancException(ErrorCode_NotImplemented); + } + } }