comparison Core/Images/ImageProcessing.cpp @ 2496:3d65adee289a

int16_t to rgba32 conversion
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 22 Mar 2018 12:53:20 +0100
parents cd7b854dbc05
children 89b789366596
comparison
equal deleted inserted replaced
2495:cd7b854dbc05 2496:3d65adee289a
592 592
593 return; 593 return;
594 } 594 }
595 595
596 if (target.GetFormat() == PixelFormat_BGRA32 && 596 if (target.GetFormat() == PixelFormat_BGRA32 &&
597 source.GetFormat() == PixelFormat_SignedGrayscale16)
598 {
599 for (unsigned int y = 0; y < source.GetHeight(); y++)
600 {
601 const int16_t* p = reinterpret_cast<const int16_t*>(source.GetConstRow(y));
602 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y));
603 for (unsigned int x = 0; x < source.GetWidth(); x++)
604 {
605 uint8_t value;
606 if (*p < 0)
607 {
608 value = 0;
609 }
610 else if (*p > 255)
611 {
612 value = 255;
613 }
614 else
615 {
616 value = static_cast<uint8_t>(*p);
617 }
618
619 q[0] = value;
620 q[1] = value;
621 q[2] = value;
622 q[3] = 255;
623 p += 1;
624 q += 4;
625 }
626 }
627
628 return;
629 }
630
631 if (target.GetFormat() == PixelFormat_BGRA32 &&
597 source.GetFormat() == PixelFormat_RGB24) 632 source.GetFormat() == PixelFormat_RGB24)
598 { 633 {
599 for (unsigned int y = 0; y < source.GetHeight(); y++) 634 for (unsigned int y = 0; y < source.GetHeight(); y++)
600 { 635 {
601 const uint8_t* p = reinterpret_cast<const uint8_t*>(source.GetConstRow(y)); 636 const uint8_t* p = reinterpret_cast<const uint8_t*>(source.GetConstRow(y));