DevILed eggs and PNGs

Today I switched my texture loader over from using ImageIO.read() to using the DevIL features. I find that the images returned from DevIL are highly saturated for some unknown reason. Is this a known problem?

Here are the comparison screenshots:

http://statezero.net/dev/sshot_imageio.png

http://statezero.net/dev/sshot_devil.png

Here is the dirt texture as a reference

http://statezero.net/dev/dirt.png

Here is the super-simple code I use to load:


   protected boolean loadInternal(String filename)
    {
        IntBuffer images = BufferUtils.createIntBuffer(1);
        IL.ilGenImages(images);
        images.rewind();
        IL.ilBindImage(images.get());
        boolean result = IL.ilLoadImage(filename);

        if (result == false)
        {
            Warning.emit("DataSourceTextureObject.loadFromStream() failed to create image from InputStream");
            return false;
        }

        setDepth((short) IL.ilGetInteger(IL.IL_IMAGE_BPP));
        setWidth((short) IL.ilGetInteger(IL.IL_IMAGE_WIDTH));
        setHeight((short) IL.ilGetInteger(IL.IL_IMAGE_HEIGHT));

        ILU.iluFlipImage();

        int numPixels = getWidth() * getHeight();
        ByteBuffer data = BufferUtils.createByteBuffer(numPixels * 4);
        IL.ilCopyPixels(0, 0, 0, getWidth(), getHeight(), 1, IL.IL_RGBA, IL.IL_BYTE, data);

        data.rewind();
        setPixels(data);

        return true;
    }

Thanks!

http://kaioa.com/k/dirt2.png

Try this image… it should look identical with both loaders.

The difference? I removed the gamma/chroma aux chunks from the png (with pngtweak).

Where is “pngtweak” util, all MrGoogle gave me was a link to this post :slight_smile:
…wait do you mean “TweakPNG” tool found here http://entropymine.com/jason/tweakpng/

Why is gamma/chroma chunks so evil in DevIL library?

Ye… tweakpng.

Why is gamma/chroma chunks so evil in DevIL library?

They aren’t really “evil”. It’s just… they either get interpreted or get ignored. If they aren’t existant (they are optional) this issue is completly avoided.

Saving pngs with pngout will also remove all optional chunks (unless specified otherwise).

Thx, I’ve now two small png utility installed. I even found pngout.dll plugin for IrfanView image tool.
http://pmt.sourceforge.net/pngcrush/
http://advsys.net/ken/utils.htm#pngout

Pngout site has pngout.dll file to be copied to IrfanView3.97 plugin folder. It provides a nice SaveAs dialog box.
http://irfanview.com/

I also use irfanview-version for a while… Before I use the command line thing via send-to, but with irfanview its much nicer to handle, because the options can be nicely accessed and there is transparency and that “finish after this pass” button thingy is also damn nice :slight_smile:

Btw there are several irfanview packs. The bigger one comes with the pngout plugin.

Other nice png programms are pngrewrite and pngquant.

“Pngrewrite is little utility that reduces the unnecessarily large palettes that too many programs write into PNG files. It also optimizes transparency settings, and reduces the bits-per-pixel if possible. Handy for post-processing images before putting them on a web site.”

“pngquant is a command-line utility to quantize and dither 32-bit RGBA PNGs down to 8-bit (or smaller) RGBA-palette PNGs, usually with a significant reduction in file size”