SFML community forums

Help => Graphics => Topic started by: emlai on July 21, 2016, 02:25:20 pm

Title: Inconsistency in sf::Image::copy
Post by: emlai on July 21, 2016, 02:25:20 pm
sf::Image::copy allows the images to overlap like this (red is the target image, green is the source image):

(http://i.imgur.com/cCmiG2r.gif)

but not like this:

(http://i.imgur.com/0peJadC.gif)

I think this behavior is inconsistent. Is there a rationale for this or is this just an oversight?
Title: Re: Inconsistency in sf::Image::copy
Post by: eXpl0it3r on July 21, 2016, 02:29:18 pm
Overlap where, when, what? Are you talking about source/destination rectangles here with your images? What is the red rectangle, what is the green rectangle?
Title: Re: Inconsistency in sf::Image::copy
Post by: emlai on July 21, 2016, 02:38:49 pm
What is the red rectangle, what is the green rectangle?

Please read the post.
Title: Re: Inconsistency in sf::Image::copy
Post by: Hiura on July 21, 2016, 03:01:12 pm
Please read this (http://en.sfml-dev.org/forums/index.php?topic=5559.0).


Title: Re: Inconsistency in sf::Image::copy
Post by: Laurent on July 21, 2016, 03:02:50 pm
The right/bottom tests are implemented here (https://github.com/SFML/SFML/blob/master/src/SFML/Graphics/Image.cpp#L214-L215). Seems like left/top would just need a similar test to make your second example work.
Title: Re: Inconsistency in sf::Image::copy
Post by: emlai on July 21, 2016, 03:32:36 pm
Seems like left/top would just need a similar test to make your second example work.

In addition to that the destX and destY parameters would need to be int, rather than unsigned int.
Title: Re: Inconsistency in sf::Image::copy
Post by: GameBear on July 21, 2016, 04:21:09 pm
since x_y coords in c++ goes like this:
--->
|
v

your first image shows the green image being added at a positive X and y coordinate on the red image
but the second shows it being added at a negative coordinate. said coordinate could be out of bounds for the image. (eg, you are trying to draw outside of the paper)

just my thoughts....