Scaling images with anti-aliasing
Stefan Fröhling (7826) 167 posts |
If I see it right there is no SWI call that offers anti-aliasing in RISC OS to scale images right? |
Simon Willcocks (1499) 513 posts |
That’s my understanding. I think you need ArtWorks, and the viewer doesn’t work on DrawFiles. The only anti-aliasing in the OS itself is for two-colour sprites, and that’s for fonts. |
Rick Murray (539) 13840 posts |
Correct. The scaling, whether sprites or JPEGs, is pretty much a case of omitting or repeating lines/rows and it’s quick, but tends to look abysmal. I wanted to have my own scaling routine in Manga (there’s some prototype code in there) but didn’t really get my head around the whole matrix thing. My scaling was nicer, but made things blurry which wasn’t quite right. So I call out to ChangeFSI which is slow but does a good job. The OS scaling routine was used as a last resort, precisely because it’s bad. |
nemo (145) 2546 posts |
Stefan asked
Correct. There was a greyscale resampler that was intended for FontManager, but that ended up becoming SuperSample and the SpriteOp (53) was removed. Simon thought
No, that doesn’t do image rescaling. You can rescale with ChangeFSI (though that doesn’t really understand gamma, so it won’t get the correct result). Rick reported
Decimation yes. Image rescaling is expensive for a number of reasons: To do it correctly it must be done in linear colour space, so you have to expand paletted data to full colour, linearise, then you have to scale, accumulate and combine both dimensions (potentially at different scales) using intermediate buffers, then gamma correct, and finally map to the destination depth. But it turns out that’s not enough either, as even the slightest rescaling has a blurring effect, so you have to sharpen too. I did all of this for the Vantage splash screen, of all things… because we needed it to load fast, yet to never be larger than 1/9th of the screen. So the RLE-compressed sprite is loaded, expanded, rescaled, sharpened, corrected, and then dithered onto the screen. We used to joke there was more technology in V’s splash screen than there was in our competitors’ products. Here it is. [Sorry, it’s so large it became an MP4 so I can’t embed it – expand that to full screen to see the detail and the difference sharpening makes] My nice desktop clock uses this technique (rescaling and sharpening): And the Twemoji Renderer does all of this (render, scale, sharpen, gamma correct) when rendering: And finally mip-mapping is a related technique for faster rendering [another too-large-for-GIF MP4, sorry]. |