ImageLoader - native extension for JPG and PNG


I’ve made a new extension!

There is png extension by @britzl and image.load() function available in Defold, but they don’t provide what I need.

image.load() is not suitable for game objects, because it’s not using a buffer object, required by resource.set_texture(). png extension can’t load jpg files and can’t load in async mode.

My new extension can load JPG, PNG and a bunch of other formats. It’s based on stb_image.h and they state they support

  JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib)
  PNG 1/2/4/8/16-bit-per-channel
  TGA (not sure what subset, if a subset)
  BMP non-1bpp, non-RLE
  PSD (composited view only, no extra channels, 8/16 bit-per-channel)
  GIF (*comp always reports as 4-channel)
  HDR (radiance rgbE format)
  PIC (Softimage PIC)
  PNM (PPM and PGM binary only)

And it can process image files on a separate thread, improving overall performance.

The project on GitHub is also a sample project.

Why would you need such extension? To load and display images downloaded from the Internet. Remember that you have to place redownloadable items such as web images into Caches directory on mobile devices. To access this directory you can use my directories extension


There is an issue has been discovered. When async mode is used, it could crash the app. Hopefully, a fix in the engine is coming soon - DEF-3761.

In the meantime, you can use no_async = true when invoking the extension with a listener.