comparison Orthanc/Core/Images/ImageProcessing.cpp @ 145:d850500b8ca6

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 08 Nov 2016 10:15:05 +0100
parents 2fffa4d0f313
children 5dc54316d68b
comparison
equal deleted inserted replaced
144:daf99382bc18 145:d850500b8ca6
517 } 517 }
518 518
519 return; 519 return;
520 } 520 }
521 521
522 if (target.GetFormat() == PixelFormat_BGRA32 &&
523 source.GetFormat() == PixelFormat_RGB24)
524 {
525 for (unsigned int y = 0; y < source.GetHeight(); y++)
526 {
527 const uint8_t* p = reinterpret_cast<const uint8_t*>(source.GetConstRow(y));
528 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y));
529 for (unsigned int x = 0; x < source.GetWidth(); x++)
530 {
531 q[0] = p[2];
532 q[1] = p[1];
533 q[2] = p[0];
534 q[3] = 255;
535 p += 3;
536 q += 4;
537 }
538 }
539
540 return;
541 }
542
522 throw OrthancException(ErrorCode_NotImplemented); 543 throw OrthancException(ErrorCode_NotImplemented);
523 } 544 }
524 545
525 546
526 547
546 SetInternal<float>(image, value); 567 SetInternal<float>(image, value);
547 return; 568 return;
548 569
549 default: 570 default:
550 throw OrthancException(ErrorCode_NotImplemented); 571 throw OrthancException(ErrorCode_NotImplemented);
572 }
573 }
574
575
576 void ImageProcessing::Set(ImageAccessor& image,
577 uint8_t red,
578 uint8_t green,
579 uint8_t blue,
580 uint8_t alpha)
581 {
582 uint8_t p[4];
583 unsigned int size;
584
585 switch (image.GetFormat())
586 {
587 case PixelFormat_RGBA32:
588 p[0] = red;
589 p[1] = green;
590 p[2] = blue;
591 p[3] = alpha;
592 size = 4;
593 break;
594
595 case PixelFormat_BGRA32:
596 p[0] = blue;
597 p[1] = green;
598 p[2] = red;
599 p[3] = alpha;
600 size = 4;
601 break;
602
603 case PixelFormat_RGB24:
604 p[0] = red;
605 p[1] = green;
606 p[2] = blue;
607 size = 3;
608 break;
609
610 default:
611 throw OrthancException(ErrorCode_NotImplemented);
612 }
613
614 for (unsigned int y = 0; y < image.GetHeight(); y++)
615 {
616 uint8_t* q = reinterpret_cast<uint8_t*>(image.GetRow(y));
617
618 for (unsigned int x = 0; x < image.GetWidth(); x++)
619 {
620 for (unsigned int i = 0; i < size; i++)
621 {
622 q[i] = p[i];
623 }
624
625 q += size;
626 }
551 } 627 }
552 } 628 }
553 629
554 630
555 void ImageProcessing::ShiftRight(ImageAccessor& image, 631 void ImageProcessing::ShiftRight(ImageAccessor& image,