GP32 Image Scaling


thejuggler

Still Fresh
Joined
Jun 8, 2004
Messages
34
Age
46
Location
UK
Website
thejuggler.net
Hi all,

I'm working on a new menu system for BOR currently, and was wondering if anyone has an example of gif scaling? I'd like to scale a 320x240 image to 1/4 size and since image manipulation is fairly common was wondering if anyone has anything already to do this. While I could sit down and write my own routines, I'm a developer and inherently lazy :)
 
Yeah, that's simple, if you want to scale down an image by 4, you can do:
-no interpolation: draw 1 pixel then don't draw three, loop...
-basic interpolation: quite the same but this time you calculate the mean of near-by pixels (the more, the blurrer), with coefficients depending on distance, on each color channel.
 
There's a couple of simple ways. Wich way is best/fastest depends on your system and coding skills. The main idea is that you have to implement lineair interpolation between two points, both horizontally and vertically. Vertical scaling is tres easy, because you can simply choose a line in sprite space for each scanline in screen space. Horizontal scaling is a bit trickier, because you have to interpolate per pixel. But instead of doing all kinds of nasty fixed point math tricks in C (wich never translate to optimal ARM assembler) you can make a table holding the scaling data for a single scanline, and use that to draw each scanline for your sprite. The gp32 has caching, so the memory reads should be quite fast.

Have fun
 
Back
Top