///////////////////////////////////////////////////////
| 567 | |
| 568 | //////////////////////////////////////////////////////////// |
| 569 | void 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 | //////////////////////////////////////////////////////////// |