Mercurial > hg > orthanc
diff Core/ImageFormats/ImageProcessing.cpp @ 1608:adc6a5704cdb
OrthancPluginConvertPixelFormat
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 02 Sep 2015 13:58:08 +0200 |
parents | 7f0aa3c0f659 |
children | 2dff2bdffdb8 |
line wrap: on
line diff
--- a/Core/ImageFormats/ImageProcessing.cpp Tue Sep 01 17:40:45 2015 +0200 +++ b/Core/ImageFormats/ImageProcessing.cpp Wed Sep 02 13:58:08 2015 +0200 @@ -378,6 +378,47 @@ return; } + if (target.GetFormat() == PixelFormat_RGB24 && + source.GetFormat() == PixelFormat_RGBA32) + { + 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[0]; + q[1] = p[1]; + q[2] = p[2]; + p += 4; + q += 3; + } + } + + return; + } + + if (target.GetFormat() == PixelFormat_RGBA32 && + source.GetFormat() == PixelFormat_RGB24) + { + 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[0]; + q[1] = p[1]; + q[2] = p[2]; + q[3] = 255; // Set the alpha channel to full opacity + p += 3; + q += 4; + } + } + + return; + } + throw OrthancException(ErrorCode_NotImplemented); }