Comments (3)
Agreed, this change sounds good. Want to submit a PR for this, including updating the documentation?
from sdl.
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.
I changed it to return the closest image if scaling fails, but otherwise this looks good. Thanks!
from sdl.
Related Issues (20)
- audio_resampleLoss failure in testautomation-no-simd HOT 36
- Suggestion: Remove SDL_SCALEMODE_BEST HOT 1
- GPU documentation unmangling
- Error message is not being freed from memory HOT 5
- GPU: vsync is always enabled HOT 4
- testyuv has incorrect colors when converting to RGB for texture upload HOT 3
- testwm shows no text HOT 3
- GPU: test code needs command line parameters to select GPU driver HOT 1
- GPU: renderer memory leaks HOT 3
- GPU: D3D12 resource memory management
- wiki problem, SDL_SetAudioStreamGetCallback HOT 1
- Compiler warnings with system locale set to JP. HOT 8
- CI doesn't show memory leak call stacks HOT 5
- GPU: Const-ify some API parameters HOT 2
- SDL3: Build fails on macOS HOT 1
- Direct3d12 renderer backend only renders black windows HOT 1
- Names of gpu backends don't match those of the 2d renderer backend HOT 3
- GPU Metal: Remove calloc usages HOT 1
- Nintendo NSO N64 Controller Mapping in Linux
- GPU: API does not follow the SDL3 naming conventions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdl.