Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Mistake in sf::Image::copy?  (Read 1609 times)

0 Members and 1 Guest are viewing this topic.

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
Mistake in sf::Image::copy?
« on: March 13, 2013, 04:24:06 pm »
I just noticed the following piece of code in sf::Image::copy (Image.cpp line 176 and 177):
if (srcRect.width  > static_cast<int>(source.m_size.x)) srcRect.width  = source.m_size.x;
if (srcRect.height > static_cast<int>(source.m_size.y)) srcRect.height = source.m_size.y;

The source rectangle may still be larger than the source texture this way (e.g. if srcRect.left > 0 and srcRect.width = width of source image).

I suppose what was meant is this:
if (srcRect.width  > static_cast<int>(source.m_size.x) - srcRect.left) srcRect.width  = source.m_size.x - srcRect.left;
if (srcRect.height > static_cast<int>(source.m_size.y) - srcRect.top ) srcRect.height = source.m_size.y - srcRect.top;
JSFML - The Java binding to SFML.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Mistake in sf::Image::copy?
« Reply #1 on: March 13, 2013, 04:41:00 pm »
I think you're right :)
Laurent Gomila - SFML developer

 

anything