Giter Club home page Giter Club logo

Comments (3)

slouken avatar slouken commented on September 13, 2024

Agreed, this change sounds good. Want to submit a PR for this, including updating the documentation?

from sdl.

Kaktus514 avatar Kaktus514 commented on September 13, 2024

Okay, I have created a PR that implements what I suggested above.

I hadn't thought about the fact that that alternate images could have different aspect ratios. I guess a smaller image could technically be a better match if the aspect ratio is closer to the aspect ratio of the main surface. It also raised the question how to decide if an image is larger if the height is smaller but the width is larger or vice versa.

What I ended up doing was to calculate the size as width × height and simply compare that to see if an image is larger or smaller. I think this is probably good enough because I don't think you're supposed to use widely different aspect ratios for the alternate images and the original code didn't handle it well anyway (the scaled image always gets the aspect ratio of the main surface).

If any call to SDL_ScaleSurface fails it simply returns NULL. This is consistent with the previous version but I wasn't sure if this was the right thing to do because in another place it returns the main surface on error.

from sdl.

slouken avatar slouken commented on September 13, 2024

I changed it to return the closest image if scaling fails, but otherwise this looks good. Thanks!

from sdl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.