MCPcopy Create free account
hub / github.com/SFML/SFML / createMaskFromColor

Method createMaskFromColor

src/SFML/Graphics/Image.cpp:569–584  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

567
568////////////////////////////////////////////////////////////
569void Image::createMaskFromColor(Color color, std::uint8_t alpha)
570{
571 // Make sure that the image is not empty
572 if (!m_pixels.empty())
573 {
574 // Replace the alpha of the pixels that match the transparent color
575 std::uint8_t* ptr = m_pixels.data();
576 std::uint8_t* end = ptr + m_pixels.size();
577 while (ptr != end)
578 {
579 if ((ptr[0] == color.r) && (ptr[1] == color.g) && (ptr[2] == color.b) && (ptr[3] == color.a))
580 ptr[3] = alpha;
581 ptr += 4;
582 }
583 }
584}
585
586
587////////////////////////////////////////////////////////////

Callers 1

Image.test.cppFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected