SFML community forums
Bindings - other languages => General => Topic started by: Eru on April 15, 2021, 12:52:08 pm
-
Hello i am learning sfml and i wonder how can i get pixels of my texture. in my project when i write
myTexture.getSize()
it gives me 512*512. But the problem is my texture is staring from (100,100)px. I mean the rest of empty with white colors. In my condition i cant crop the empty blanks from my image.png file. So, can i pull the starting pixels of my texture/image? Is it possible?
-
sf::Texture::loadFromFile() also allows you to supply an sf::IntRect which defines a smaller part of the texture you want to load
https://www.sfml-dev.org/tutorials/2.5/graphics-sprite.php#loading-a-texture
You can also use sf::Sprite::setTextureRect() to display only part of a texture
https://www.sfml-dev.org/tutorials/2.5/graphics-sprite.php#ok-can-i-have-my-sprite-now