Thread overview
Reading image files
Nov 25, 2016
solidstate1991
Nov 25, 2016
Ali Çehreli
Nov 26, 2016
Mike Parker
November 25, 2016
After I couldn't figure out how to convert Imageformats' own format to my own (consequential read from IFImage resulted in a glitchy image after rendering the result) and I have no idea how DerelictFI works at all, I'm currently out of options. At least I need PNG and TGA (the latter is important as my rendering engine relies on transparencies), the best could be is to be able to read paletted bitmaps directly, which is a missing feature in Imageformats.
November 25, 2016
On 11/25/2016 12:10 PM, solidstate1991 wrote:
> After I couldn't figure out how to convert Imageformats' own format to
> my own (consequential read from IFImage resulted in a glitchy image
> after rendering the result) and I have no idea how DerelictFI works at
> all, I'm currently out of options. At least I need PNG and TGA (the
> latter is important as my rendering engine relies on transparencies),
> the best could be is to be able to read paletted bitmaps directly, which
> is a missing feature in Imageformats.

I'm not an expert this domain at all but I have an experimental project that uses ImageMagick('s C library), which supports those and many other image formats. I had written the following binding file for the project:

  https://github.com/acehreli/alibum/blob/master/magickwand.d

Ali

November 26, 2016
On Friday, 25 November 2016 at 20:10:56 UTC, solidstate1991 wrote:
> 
> glitchy image after rendering the result) and I have no idea how DerelictFI works at all,

DerelictFI is just a binding to FreeImage, so the more relevant point to consider is how FreeImage works :-) Everything you need to know can be found at [1]. Download the FreeImage DLL for Windows, or install it via your package manager on other systems. Then add DerelictFI as a dependency to your dub configuration [2] (I suggest version "~>2.0.3" -- don't use the alpha version), then you can do this:

import derelict.freeimage.freeimage;

void main() {
    DerelictFI.load();
}

This loads the FreeImage shared library into your process space if it's on your system path. (on Windows, you should make sure the DLL is in the same directory as your executable). From then on, you can call FreeImage functions as per the project's documentation.

[1] http://freeimage.sourceforge.net/
[2] https://code.dlang.org/packages/derelict-fi