The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Avoiding "aliasing" in very big scalled down image
ShiroAisu


Joined: 09 Jun 2010
Posts: 42
How would I go about having a smooth image even when I resize a big image to a small size? This is what I'm trying to avoid:



This particular image is not even that big (3000*3000).

One thing I tried was generating mipmaps and using the mipmap level that is nearest to the wanted size. My reasoning behind this was that maybe this happens because, since the image is being resized by more than half, some pixels were being lost. This didn't help much however:



This is the second mipmap, scaled by a factor of .72, (for comparrison, the original image is scaled by a factor of .36), but as you can tell it is not much better...

So what is the solution here? I know that with raw OpenGL I can get clear images by choosing to use mipmaps (I think), which was also a reason why I tried that. Am I just missinterpreting the idea of mipmaps? Am I using them wrong? Is the result I'm looking for not possible using linear interpolation?

Thank you in advance for all the help.[/img]
Avoiding "aliasing" in very big scalled down image
Juan Manuel Borges Caño
Guest

Though i expected that you were about to ask about SDL Resizing Hint:
How (OpenGL) Texture Scaling Works -The Benny Box:
< http://www.youtube.com/watch?v=55RI5_hgKUY&feature=youtube_gdata_player >.
The Channel Has A Lot Of (OpenGL) Marbles.
Hope you Learn, Hope you Enjoy Wink
ShiroAisu


Joined: 09 Jun 2010
Posts: 42
Thank you for the resource, but right after I posted this I went on to research mipmaps a bit more and as such I know what they do and how to get them.

I'm definitely generating the mipmaps right, but for some reason there is jaggedness once I zoom the mipmaps (in or out), for instance, this is a program I made to test my mipmapping, and the original image is about 3000 * 4000 or something like that. As you can see, this is the 2nd (I believe) level of mipmapping and while I render it at its normal size it looks perfect:



However, when I start zooming in or out even just a little, I get these jagged edges:

1.1 * zoom relative to the mipmap size:


0.9 * zoom relative to the mipmap size:


I cannot find any documentation on this whatsoever, and I've never encountered this behavior before.
Any ideas?[/img]
ShiroAisu


Joined: 09 Jun 2010
Posts: 42
Well, I did it guys, and I also think I might be retarded.

Apparently SDL uses nearest interpolation by default, which is a well documented fact, but for some reason I had in my head that it used linear by default. Today I tought "Ok, lets just check, JUST TO MAKE SURE" and yeah... I changed the render scale hint to linear and it works now.

Anyway, solved I guess, and boy am I relieved.