Page 1 of 2

DDS support

Posted: 2008-02-25T10:18:54-07:00
by Pecunia
A while ago I needed to convert a lot of DDS files to PNG, so I wrote some code so "convert" could read DDS files. Right now I have some spare time to clean up the code and add support for more DDS compression formats; I don't intend to support writing DDS files.

In short, my question is: how do I submit my code for inclusion in the ImageMagick project once I'm done cleaning it up?

Re: DDS support

Posted: 2008-02-25T10:29:54-07:00
by magick
You can post a URL to your patch here and we will add it to the source base. If you can do 2 of these miracles: walk on water, heal the sick, or raise the dead-- we can give you update privileges to the ImageMagick Subversion repository.

Re: DDS support

Posted: 2008-02-27T13:30:40-07:00
by Pecunia
Thanks for the fast reply :)

I'm learning more about the DDS format, and bumped into a few "issues". I have only dealt with flat, 2d images before, so I'm wondering how these should be handled in my DDS coder:
- Mipmaps - smaller scale versions of the same image.
- Cube maps, where several (usually all 6) faces of a cube are defined.
- Volume maps.. 3d images.

Could you give me some advice on what to do with the above, or point me to coders for other image formats which deal with the same issues?

Re: DDS support

Posted: 2008-02-27T13:57:30-07:00
by magick
Our general solution to the problem is to create a multi-image sequence. For volume maps, for example, the image sequence represents 2D slices through the 3D volume or in the case of cube maps the sequence is 6 images, each representing a face of the cube.

Re: DDS support

Posted: 2008-02-27T14:33:42-07:00
by Pecunia
Alright, I'll try to do that.

And the mipmaps... ignore them or also put them in the multi-image sequence? (according to the specs even volume maps can have mipmaps :shock:)

Re: DDS support

Posted: 2008-03-05T12:41:46-07:00
by Pecunia
Okay, my DDS coder is done; I've put the patch (against 6.3.9-0) here.

Supported DDS files:
- Texture files
- Cube maps
- Volume maps

Supported DDS compression formats:
- Uncompressed, RGB and RGBA
- DXT1
- DXT3
- DXT5

Re: DDS support

Posted: 2008-03-05T12:56:21-07:00
by magick
We applied your patch against ImageMagick-6.3.9-2 Beta. In addition, post a URL to a few DDS images so we can add regressions tests against this format. Thanks.

Re: DDS support

Posted: 2008-03-05T13:59:44-07:00
by Pecunia
Sample images here: [dead link removed]
Either grab the images individually or get the all_files.tar.bz2 which includes all images :)

Re: DDS support

Posted: 2008-03-05T14:23:10-07:00
by magick
The URL you posted gets a connection timed-out exception. Will try again later.

Re: DDS support

Posted: 2008-03-08T01:26:17-07:00
by Pecunia
Must have been a little hiccup in my internet connection. I see two entries in the access log for the bzip2 file... did you get it?

Re: DDS support

Posted: 2008-03-08T07:38:35-07:00
by magick
DDS support is in the current ImageMagick release, 6.3.9-3. Download and test it when you get a chance and verify its working as expected.

Re: DDS support

Posted: 2008-03-08T09:17:00-07:00
by Pecunia
Building ImageMagick 6.3.9-3 failed in the SVG coder with the following error:

Code: Select all

/bin/sh ./libtool --silent --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I./config   -I/usr/include/librsvg-2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0    -I/usr/include/freetype2 -I/usr/X11R6/include -I/usr/include/libxml2  -g -O2 -Wall -W -pthread -MT coders/coders_svg_la-svg.lo -MD -MP -MF coders/.deps/coders_svg_la-svg.Tpo -c -o coders/coders_svg_la-svg.lo `test -f 'coders/svg.c' || echo './'`coders/svg.c
In file included from coders/svg.c:96:
/usr/include/librsvg-2/librsvg/rsvg-cairo.h:28:19: error: cairo.h: No such file or directory
In file included from coders/svg.c:96:
/usr/include/librsvg-2/librsvg/rsvg-cairo.h:33: error: expected declaration specifiers or '...' before 'cairo_t'
/usr/include/librsvg-2/librsvg/rsvg-cairo.h:36: error: expected declaration specifiers or '...' before 'cairo_t'
coders/svg.c: In function 'SVGSetDocumentLocator':
coders/svg.c:675: warning: unused parameter 'location'
coders/svg.c: In function 'ReadSVGImage':
coders/svg.c:2657: warning: missing initializer
coders/svg.c:2657: warning: (near initialization for 'SAXModules.initialized')
coders/svg.c:2704: error: 'cairo_surface_t' undeclared (first use in this function)
coders/svg.c:2704: error: (Each undeclared identifier is reported only once
coders/svg.c:2704: error: for each function it appears in.)
coders/svg.c:2705: error: 'cairo_surface' undeclared (first use in this function)
coders/svg.c:2707: error: 'cairo_t' undeclared (first use in this function)
coders/svg.c:2708: error: 'cairo_info' undeclared (first use in this function)
coders/svg.c:2776: warning: implicit declaration of function 'cairo_image_surface_create_for_data'
coders/svg.c:2777: error: 'CAIRO_FORMAT_ARGB32' undeclared (first use in this function)
coders/svg.c:2778: error: expected expression before ')' token
coders/svg.c:2784: warning: implicit declaration of function 'cairo_create'
coders/svg.c:2785: warning: implicit declaration of function 'cairo_scale'
coders/svg.c:2786: warning: implicit declaration of function 'cairo_set_operator'
coders/svg.c:2786: error: 'CAIRO_OPERATOR_CLEAR' undeclared (first use in this function)
coders/svg.c:2787: warning: implicit declaration of function 'cairo_paint'
coders/svg.c:2788: error: 'CAIRO_OPERATOR_OVER' undeclared (first use in this function)
coders/svg.c:2789: error: too many arguments to function 'rsvg_handle_render_cairo'
coders/svg.c:2790: warning: implicit declaration of function 'cairo_destroy'
coders/svg.c:2791: warning: implicit declaration of function 'cairo_surface_destroy'
make[1]: *** [coders/coders_svg_la-svg.lo] Error 1
make[1]: Leaving directory `/home/bianca/sources/ImageMagick-6.3.9'
make: *** [all] Error 2
The cairo.h header file is located in /usr/include/cairo/ on my machine; adding that path to the compile command solved the issue.

After compiling, I ran "convert" on every DDS file I have available, it's working entirely as expected :)

Re: DDS support

Posted: 2008-03-08T10:25:33-07:00
by magick
The RSVG developers need to change the <cairo.h> include to <cairo/cairo.h>. In the mean-time we check for the cairo-svg package (which apparently is not installed on your system) which defines the c-flags for this header file. We'll enhance the configure script to also look for the cairo package to determine the location of the cairo.h header file. Download ImageMagick 6.3.9-4 beta from ftp://magick.imagemagick.org/pub/ImageMagick/beta in a few hours and let us know if it works.

Re: DDS support

Posted: 2008-03-08T13:19:56-07:00
by Pecunia
I downloaded the .bz2 dated 03/08/08 17:51:00: still the same error.

My system is a custom-built Linux From Scratch from November last year, with cairo 1.4.10 and librsvg 2.16.1 installed. There is a cairo-svg.pc file in /usr/lib/pkgconfig with the right Cflags.

Looking further into this: ./configure said that neither cairo nor cairo-svg was available. Digging into the config.log file revealed:

Code: Select all

configure:38627: checking for CAIRO
configure:38635: $PKG_CONFIG --exists --print-errors "cairo"
Package xrender was not found in the pkg-config search path.
Perhaps you should add the directory containing `xrender.pc'
to the PKG_CONFIG_PATH environment variable
Package 'xrender', required by 'cairo', not found
... which makes sense, because Xorg is installed in /usr/X11R6, and I didn't have its pkgconfig path added to PKG_CONFIG_PATH env variable.

Still, if cairo (or cairo-svg) isn't available, the SVG module should be disabled and not throw an error when compiling, right?

Re: DDS support

Posted: 2008-03-08T13:39:20-07:00
by magick
Ok, fixed configure to only accept RSVG if both rsvg and cairo-svg package tests pass. Download ImageMagick 6.3.9-4 Beta in about 2 hours to test.