comparison Core/Images/ImageProcessing.cpp @ 2840:f4c232bba1eb

bgra32 to grayscale conversion
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 25 Sep 2018 10:17:59 +0200
parents 65699fcb4e99
children da43ef7ff32a
comparison
equal deleted inserted replaced
2839:0d8b753317b2 2840:f4c232bba1eb
467 } 467 }
468 468
469 return; 469 return;
470 } 470 }
471 471
472 if (target.GetFormat() == PixelFormat_Grayscale8 &&
473 source.GetFormat() == PixelFormat_BGRA32)
474 {
475 for (unsigned int y = 0; y < source.GetHeight(); y++)
476 {
477 const uint8_t* p = reinterpret_cast<const uint8_t*>(source.GetConstRow(y));
478 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y));
479 for (unsigned int x = 0; x < source.GetWidth(); x++, q++)
480 {
481 *q = static_cast<uint8_t>((2126 * static_cast<uint32_t>(p[2]) +
482 7152 * static_cast<uint32_t>(p[1]) +
483 0722 * static_cast<uint32_t>(p[0])) / 10000);
484 p += 4;
485 }
486 }
487
488 return;
489 }
490
472 if (target.GetFormat() == PixelFormat_RGB24 && 491 if (target.GetFormat() == PixelFormat_RGB24 &&
473 source.GetFormat() == PixelFormat_RGBA32) 492 source.GetFormat() == PixelFormat_RGBA32)
474 { 493 {
475 for (unsigned int y = 0; y < source.GetHeight(); y++) 494 for (unsigned int y = 0; y < source.GetHeight(); y++)
476 { 495 {