SFML community forums

Help => Graphics => Topic started by: panithadrum on February 18, 2010, 11:02:16 pm

Title: sf::Image::Copy
Post by: panithadrum 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?
Title: sf::Image::Copy
Post by: gsaurus 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)?
Title: sf::Image::Copy
Post by: panithadrum 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:
Title: sf::Image::Copy
Post by: Laurent on February 19, 2010, 12:25:38 pm
Many things in the documentation need more details ;)