SFML community forums
Help => Graphics => Topic started by: nbd on March 18, 2014, 03:46:45 pm
-
Is there a way to initialize an image (sf::Image or sf::Texture ) with only a portion (region) of other image? Say, one have a source 1000x1000 image and a destination 100x100 image. Is there a way to copy into the destination image a 100x100 region of the source image with specified coordinates?
-
Did you even care to look at the documentation? ;)
The sf::Image has a copy (http://www.sfml-dev.org/documentation/2.1/classsf_1_1Image.php#ab2fa337c956f85f93377dcb52153a45a) function that lets you do so.
For textures you can specify an area to be loaded (see here (http://www.sfml-dev.org/documentation/2.1/classsf_1_1Texture.php#a8e1b56eabfe33e2e0e1cb03712c7fcc7)), but if you want to change it later, you might want to use a texture rect in a sprite, otherwise you'll have to go via a render texture, which might not always be what you want.
-
Thankx! (I read documentation about Image, but looked only to constructors since I thought that if there is way to copy a part of an image, it would be logical to have a constructor with such an option. )
-
Thankx! (I read documentation about Image, but looked only to constructors since I thought that if there is way to copy a part of an image, it would be logical to have a constructor with such an option. )
SFML tends to have lots of stuff in functions rather than in the constructor, just for future reference.