I want to generate mipmaps for 2D textures as an offline step. My priority is for image quality, execution time is not a concern. The images will, naturally, always be halved and will always be powers-of-2.

I've found this fine article on the subject, which was helpful, but I don't have much knowledge on filtering, so I'm not very sure where to start.

I'm looking for algorithms and hopefully some sample implementations that I can base myself on. Also, using a third party library is an option, as long as it is open source and portable C or C++.

Any help is appreciated.

  • \$\begingroup\$ For offline generation I'm not certain why you have the open-source/portable requirements. Surely you can just generate them on any machine then ship them with your game. Whether or not the generated mips will be portable depends on your chosen format, not your generation tool (provided it supports the format, of course). You may be limiting your options with these requirements. \$\endgroup\$ – Maximus Minimus May 5 '14 at 18:48
  • \$\begingroup\$ Are you looking for code or does a plugin for Photoshop suffice? \$\endgroup\$ – Jonas Bötel May 5 '14 at 18:53
  • \$\begingroup\$ Yes, I agree with you Jimmy. What I really want to avoid is licensing issues. That's why open source libraries would be best. @LumpN code of any kind that I can use as a reference. I wish to integrate this with a custom tool. \$\endgroup\$ – glampert May 5 '14 at 18:56

You might look into ImageMagick. It's open-source and contains code for resampling images using a variety of filters including Lanczos, Kaiser, Gaussian, etc. It can be used as a library linked into your code, and/or as a set of command-line tools you can call from shell scripts and suchlike.


I have settled with the NVidia Texture Tools library. It has a lot of good texture filters plus other things that might be useful in the future, such as GPU accelerated DXT texture compression. The library is Open Source and released under the MIT licence, which is very unrestrictive.

Thanks for all the replies and comments.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.