DerelictSDLImage

DerelictSDLImage is a D binding to Sam Lantinga's SDL_image, a cross-platform image loading library designed to be used together with SDL.

The current version of DerelictSDLImage requires SDL_image 1.2.8 or later.

Building

To compile DerelictSDLImage, add the DerelictSDLImage make target to the command line when compiling Derelict. For example, to build DerelictSDLImage on Windows with DMD, you would execute the following:

make -fwin32.mak DerelictSDLImage DC=DMD
For more information on compiling Derelict libraries, see Building the Derelict Bindings.

Using

  1. Always make sure the DerelictSDL source modules are available on your import path.
  2. In modules that make use of DerelictSDLImage, you will need to import the derelict.sdl.image and derelict.sdl.sdl modules.
  3. You must link your application with the DerelictSDL, DerelictSDLImage and DerelictUtil libraries.
  4. Before calling any SDL_image functions, you need to make a call to DerelictSDLImage.load. This will load the shared library.

The following is a complete program that loads DerelictSDLImage:


import derelict.sdl.image;

void main()
{
    DerelictSDLImage.load();

    // now you can call SDL_image functions
}

As with other Derelict bindings, DerelictSDLImage will throw an exception if an error occurs while loading the shared library. For more information on Derelict exceptions, see the documentation for Using the Derelict Bindings.

Finally, the method DerelictSDLImage.unload() is provided for convenience. In normal practice you do not need to call this function, as Derelict will unload the library automatically when the app exits. You generally should only use this function if you need to unload DerelictSDLImage while the application is running or if you disable the automatic unloading of shared libraries (as per the documentation for the loader module).