SFML community forums

Help => Graphics => Topic started by: DevDavisNunez on July 18, 2016, 04:14:59 am

Title: Unify the images functions?
Post by: DevDavisNunez on July 18, 2016, 04:14:59 am
Hi good day!

I have been working for several weeks with SFML,

Everything is going great, I should mention, but I found inconvenient,

I require work almost all the features available in modules, sprites, texture, image, and according eh tested and researched, it is not convenient to be moving from one format to another in each cycle :P

Someone knows somehow that I can help unify formats?

For example in the sprite, I can do "smooth" I can access the pixels, also can apply effects "flip, vertical and horizontal" Knowing the size in pixels, and can scale the size.

Someone could help me or direct me?

Regards!
Title: Re: Unify the images functions?
Post by: DarkRoku12 on July 18, 2016, 05:16:11 am
You should know that sf::Texture is not sf::Image .

sf::Texture is an OpenGL resource.
sf::Image is a matrix of uint8 (0~255) type.

If you need this functionality you can create a custom class with, Texture and Image, then define your owns methods.

Defines a method that whenever the image is modified the texture is (re)-loaded.

All drawables using the texture will be updated too if the texture is changed.
Title: Re: Unify the images functions?
Post by: Hapax on July 18, 2016, 02:51:04 pm
it is not convenient to be moving from one format to another in each cycle :P
Which ones are you moving amongst in each cycle? Are you moving backwards and forwards from image and texture? If so, why, what are you trying to achieve?

For example in the sprite, I can do "smooth" I can access the pixels, also can apply effects "flip, vertical and horizontal" Knowing the size in pixels, and can scale the size.
You can't actually add smooth to a sprite but you can add smooth to the texture that it uses - a sprite is a just a way of stating how a texture (or part of a texture) should be displayed.
Flips are simple by setting the scale to negative values or setting the texture rectangle to negative sizes.
Scaling to a specific pixel size can be done by calculating the ratio of scale that you need (target size / original size).
Setting the scale using a target size can be useful sometimes and is why I included it (https://github.com/Hapaxia/SelbaWard/wiki/Gallery-Sprite#visual-representation) in Selba Ward's Gallery Sprite (https://github.com/Hapaxia/SelbaWard/wiki/Gallery-Sprite)  ;)