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

Author Topic: sf::Image::Copy  (Read 3370 times)

0 Members and 1 Guest are viewing this topic.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
sf::Image::Copy
« on: February 18, 2010, 11:02:16 pm »
I'm having problems copying an image to another.
Code: [Select]
sf::Image texture;
if(!texture.LoadFromFile(fname)) return false;
sf::Image subtexture;
subtexture.Copy(texture, 0, 0, sf::IntRect(x, y, width, height), true);


Console shows that I am trying to access an empty image, but texture was successfull loaded... I am using SFML2, last version, W7.

Any idea why?

gsaurus

  • Sr. Member
  • ****
  • Posts: 262
    • View Profile
    • Evolution Engine
sf::Image::Copy
« Reply #1 on: February 18, 2010, 11:56:58 pm »
subtexture is empty.
I think that copy requires the target image to have enough space to paste the source area  being copied.

Edit: Ok, looking at SFML code, as I though, copy doesn't change target size, it copies what it can to the target. Since target is empty, it just returns.
Aren't you trying to access subtexture pixels later (which is empty)?
Pluma - Plug-in Management Framework

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
sf::Image::Copy
« Reply #2 on: February 19, 2010, 12:17:34 pm »
Hmm that makes sense. It's solved now. Maybe documentation needs some details to be added  :oops:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Image::Copy
« Reply #3 on: February 19, 2010, 12:25:38 pm »
Many things in the documentation need more details ;)
Laurent Gomila - SFML developer