« Black Friday and Cybe… | Home | Heise Mac Dev »

ImageMagick 7 for Xojo


In the last weeks we worked on a bigger project for our Xojo plugins. As you may know we support both GraphicsMagick and ImageMagick libraries in our plugin. For GraphicsMagick we build the library and embed it in our plugins. For ImageMagick we do not embed the library, so you need to bring your own library file. In our Xojo plugins we used to be based on version 6.9 of ImageMagick and we have three configurations: 8, 16 and 32 bit depth. We have each class for ImageMagick three times and by using one of the classes, you pick the depth you want, e.g. IMImageQ16MBS class for 16 bit. Then you need to load at runtime in your application the right library (DLL/dylib/so) and the classes can work.

For Image Magic 7 the API changes significantly. Half of the plugin code needed an update or rewrite. As we had to rewrite, we took a bigger approach. We created a new set of classes, all with 7 in the name. As ImageMagick now supports High Dynamic Range Images in the HDRI versions of the library, we got 7 combinations of 8, 16, 32, 64 bit with and without HDRI (There is no 64bit without HDRI). For a time we had all classes compiled in 7 versions, but this was not the designed we liked. How would it be to have one class which adapts?

After a few changes to the plugin code we got exactly this. You load the library and we run a few functions to ask the library whether it supports HDRI and what the desired depth is. In our functions to fill an image with a Xojo picture, we now branch out to the right code to convert a pixel from 8 bit in Xojo per channel into the desired bit depth. Yes, we have 7 functions in C code for this and use the right one.

You can simply download the current ImageMagick libraries from the website, e.g. ImageMagick-x86_64-apple-darwin19.0.0.tar.gz for MacOS or ImageMagick-7.0.9-7-Q16-HDRI-x64-dll.exe for Windows 64-bit. On Windows with installer just install it and the path environment variable points to the right folder, so you can just load the DLL by name. For MacOS, please point to the right dylib file. This works fine for us with 16 bit color depth on Mac and 16 bit HDRI on Windows.

Please try the new ImageMagick7 classes. ImageMagick is a huge library. We have already over 200 methods there to edit images with a lot of effects. But we are not yet done. But if you see a method you miss, please contact us.
03 12 19 - 18:42