Mercurial > hg > orthanc
diff Core/Images/ImageProcessing.cpp @ 2089:7a969f235adf
PixelFormat_BGRA32
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 19 Sep 2016 17:22:41 +0200 |
parents | 4d099fee5eca |
children | 1554fc153a93 |
line wrap: on
line diff
--- a/Core/Images/ImageProcessing.cpp Fri Sep 16 12:22:30 2016 +0200 +++ b/Core/Images/ImageProcessing.cpp Mon Sep 19 17:22:41 2016 +0200 @@ -552,6 +552,61 @@ } + void ImageProcessing::Set(ImageAccessor& image, + uint8_t red, + uint8_t green, + uint8_t blue, + uint8_t alpha) + { + uint8_t p[4]; + unsigned int size; + + switch (image.GetFormat()) + { + case PixelFormat_RGBA32: + p[0] = red; + p[1] = green; + p[2] = blue; + p[3] = alpha; + size = 4; + break; + + case PixelFormat_BGRA32: + p[0] = blue; + p[1] = green; + p[2] = red; + p[3] = alpha; + size = 4; + break; + + case PixelFormat_RGB24: + p[0] = red; + p[1] = green; + p[2] = blue; + size = 3; + break; + + default: + throw OrthancException(ErrorCode_NotImplemented); + } + + for (unsigned int y = 0; y < image.GetHeight(); y++) + { + uint8_t* q = reinterpret_cast<uint8_t*>(image.GetRow(y)); + + for (unsigned int x = 0; x < image.GetWidth(); x++) + { + for (unsigned int i = 0; i < size; i++) + { + q[i] = p[i]; + } + + q += size; + } + } + } + + void ImageProcessing::ShiftRight(ImageAccessor& image, unsigned int shift) {