Hi!
This topic is about a recent problem I'm having with texture loading, specifically with JPG's. I'll explain the problem keeping it as short as possible with both text and images.
One of the projects I'm currently working at requires me to load a series of image files, apply some processing to then export them.
The code I use to load the images is:
bool res = sfml_tex_->loadFromFile(path.c_str());
if(true == res) {
sf::Vector2u _size = sfml_tex_->getSize();
size_.x_ = _size.x; size_.y_ = _size.y;
new_size_ = size_;
extension_ = ext;
}
Where:
- sfml_tex_ is a VALID pointer to sf::Texture
- path is the path (in disk) to the texture to load
It is fair to assume that if loadFromFile returns false it is ALWAYS my fault. Assuming that the paths are everything correct, loadFromFile ALWAYS returns true, everything is fine up until this point.
The problem comes when trying to load a JPG file. The problem I'm encountering is that the loading function (loadFromFile) is flipping the width and the height of the image (I'm assuming it is because it makes the loading process faster).
In the following screenshot, it is clear that the size of the image is 1901x2852 pixels:
https://i.imgur.com/EN8wBXp.pngBut when debugging it, the values are stored the other way around (width is stored in height and viceversa):
https://i.imgur.com/yemVuF2.pngThe image IS EXACTLY THE SAME but with flipped width and height.
This presents a very important problem for me because I need to apply rotation to the images before exporting them (applying the rotation is not the problem).
I've also attached the images to this post.
Again the intention of this DOESN'T INCLUDE DRAWING THE TEXTURES, only loading them and applying processes to them, I'm using SFML because it provides the tools I need to draw them, but that is not the main point.
Please let me know if any extra information is needed, thanks in advance