简体   繁体   中英

SFML Sprite resizing error

Whenever I try to resize a sprite using sfml 1.6 Sprite.Resize(x,y) function, it just copies whatever is on the rightmost and bottommost sides as many times as it needs to to make it that size. Is there a way to get it to actually scale the image? I have a 30 by 30 image that I want to rescale to be 90 by 90, but this is what happens (first picture is the 90 by 90 it gives me, second is the 30 by 30 that I give it).

Also, I just found that in this code:

    void changeI(sf::Image I,int x,int y){
        std::cout<<"h"<<std::endl;
        CI = I; // CI is another sf::Image object declared earlier in my code
        CS.SetImage(CI);
}

If I change it to this:

        void changeI(sf::Image I,int x,int y){
            std::cout<<"h"<<std::endl;
            CI = I;
            CS.SetImage(I); //changed CI to I here 

It doesn't show anything instead of the image showing up with the strange buffers on the side.

I found a solution, this is a rather annoying error, when you first set the sprite to an image, make sure to use the smallest you intend to, then resize it to whatever you want it at. Then, you can use whatever images you want. I guess this is just an oversight by SFML, hopefully they will fix it in SFML 2.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM