comparison 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
comparison
equal deleted inserted replaced
2088:b9428d5f7eaf 2089:7a969f235adf
550 throw OrthancException(ErrorCode_NotImplemented); 550 throw OrthancException(ErrorCode_NotImplemented);
551 } 551 }
552 } 552 }
553 553
554 554
555 void ImageProcessing::Set(ImageAccessor& image,
556 uint8_t red,
557 uint8_t green,
558 uint8_t blue,
559 uint8_t alpha)
560 {
561 uint8_t p[4];
562 unsigned int size;
563
564 switch (image.GetFormat())
565 {
566 case PixelFormat_RGBA32:
567 p[0] = red;
568 p[1] = green;
569 p[2] = blue;
570 p[3] = alpha;
571 size = 4;
572 break;
573
574 case PixelFormat_BGRA32:
575 p[0] = blue;
576 p[1] = green;
577 p[2] = red;
578 p[3] = alpha;
579 size = 4;
580 break;
581
582 case PixelFormat_RGB24:
583 p[0] = red;
584 p[1] = green;
585 p[2] = blue;
586 size = 3;
587 break;
588
589 default:
590 throw OrthancException(ErrorCode_NotImplemented);
591 }
592
593 for (unsigned int y = 0; y < image.GetHeight(); y++)
594 {
595 uint8_t* q = reinterpret_cast<uint8_t*>(image.GetRow(y));
596
597 for (unsigned int x = 0; x < image.GetWidth(); x++)
598 {
599 for (unsigned int i = 0; i < size; i++)
600 {
601 q[i] = p[i];
602 }
603
604 q += size;
605 }
606 }
607 }
608
609
555 void ImageProcessing::ShiftRight(ImageAccessor& image, 610 void ImageProcessing::ShiftRight(ImageAccessor& image,
556 unsigned int shift) 611 unsigned int shift)
557 { 612 {
558 if (image.GetWidth() == 0 || 613 if (image.GetWidth() == 0 ||
559 image.GetHeight() == 0 || 614 image.GetHeight() == 0 ||