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

Method flipHorizontally

src/SFML/Graphics/Image.cpp:716–737  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

714
715////////////////////////////////////////////////////////////
716void Image::flipHorizontally()
717{
718 if (!m_pixels.empty())
719 {
720 const std::size_t rowSize = m_size.x * 4;
721
722 for (std::size_t y = 0; y < m_size.y; ++y)
723 {
724 auto left = m_pixels.begin() + static_cast<std::vector<std::uint8_t>::iterator::difference_type>(y * rowSize);
725 auto right = m_pixels.begin() +
726 static_cast<std::vector<std::uint8_t>::iterator::difference_type>((y + 1) * rowSize - 4);
727
728 for (std::size_t x = 0; x < m_size.x / 2; ++x)
729 {
730 std::swap_ranges(left, left + 4, right);
731
732 left += 4;
733 right -= 4;
734 }
735 }
736 }
737}
738
739
740////////////////////////////////////////////////////////////

Callers 1

Image.test.cppFile · 0.80

Calls 1

beginMethod · 0.45

Tested by

no test coverage detected