Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
1607:a1c92fd4d26d | 1608:adc6a5704cdb |
---|---|
376 { | 376 { |
377 ConvertColorToGrayscale<int16_t>(target, source); | 377 ConvertColorToGrayscale<int16_t>(target, source); |
378 return; | 378 return; |
379 } | 379 } |
380 | 380 |
381 if (target.GetFormat() == PixelFormat_RGB24 && | |
382 source.GetFormat() == PixelFormat_RGBA32) | |
383 { | |
384 for (unsigned int y = 0; y < source.GetHeight(); y++) | |
385 { | |
386 const uint8_t* p = reinterpret_cast<const uint8_t*>(source.GetConstRow(y)); | |
387 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y)); | |
388 for (unsigned int x = 0; x < source.GetWidth(); x++) | |
389 { | |
390 q[0] = p[0]; | |
391 q[1] = p[1]; | |
392 q[2] = p[2]; | |
393 p += 4; | |
394 q += 3; | |
395 } | |
396 } | |
397 | |
398 return; | |
399 } | |
400 | |
401 if (target.GetFormat() == PixelFormat_RGBA32 && | |
402 source.GetFormat() == PixelFormat_RGB24) | |
403 { | |
404 for (unsigned int y = 0; y < source.GetHeight(); y++) | |
405 { | |
406 const uint8_t* p = reinterpret_cast<const uint8_t*>(source.GetConstRow(y)); | |
407 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y)); | |
408 for (unsigned int x = 0; x < source.GetWidth(); x++) | |
409 { | |
410 q[0] = p[0]; | |
411 q[1] = p[1]; | |
412 q[2] = p[2]; | |
413 q[3] = 255; // Set the alpha channel to full opacity | |
414 p += 3; | |
415 q += 4; | |
416 } | |
417 } | |
418 | |
419 return; | |
420 } | |
421 | |
381 throw OrthancException(ErrorCode_NotImplemented); | 422 throw OrthancException(ErrorCode_NotImplemented); |
382 } | 423 } |
383 | 424 |
384 | 425 |
385 | 426 |