DDS support

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Pecunia

DDS support

Post by Pecunia » 2008-02-25T10:18:54-07:00

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?

User avatar
magick
Site Admin
Posts: 10995
Joined: 2003-05-31T11:32:55-07:00

Re: DDS support

Post by magick » 2008-02-25T10:29:54-07:00

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.

Pecunia

Re: DDS support

Post by Pecunia » 2008-02-27T13:30:40-07:00

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?

User avatar
magick
Site Admin
Posts: 10995
Joined: 2003-05-31T11:32:55-07:00

Re: DDS support

Post by magick » 2008-02-27T13:57:30-07:00

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.

Pecunia

Re: DDS support

Post by Pecunia » 2008-02-27T14:33:42-07:00

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:)

Pecunia

Re: DDS support

Post by Pecunia » 2008-03-05T12:41:46-07:00

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

User avatar
magick
Site Admin
Posts: 10995
Joined: 2003-05-31T11:32:55-07:00

Re: DDS support

Post by magick » 2008-03-05T12:56:21-07:00

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.

Pecunia

Re: DDS support

Post by Pecunia » 2008-03-05T13:59:44-07:00

Sample images here: [dead link removed]
Either grab the images individually or get the all_files.tar.bz2 which includes all images :)
Last edited by Pecunia on 2008-12-19T03:39:51-07:00, edited 1 time in total.

User avatar
magick
Site Admin
Posts: 10995
Joined: 2003-05-31T11:32:55-07:00

Re: DDS support

Post by magick » 2008-03-05T14:23:10-07:00

The URL you posted gets a connection timed-out exception. Will try again later.

Pecunia

Re: DDS support

Post by Pecunia » 2008-03-08T01:26:17-07:00

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?

User avatar
magick
Site Admin
Posts: 10995
Joined: 2003-05-31T11:32:55-07:00

Re: DDS support

Post by magick » 2008-03-08T07:38:35-07:00

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.

Pecunia

Re: DDS support

Post by Pecunia » 2008-03-08T09:17:00-07:00

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 :)

User avatar
magick
Site Admin
Posts: 10995
Joined: 2003-05-31T11:32:55-07:00

Re: DDS support

Post by magick » 2008-03-08T10:25:33-07:00

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.

Pecunia

Re: DDS support

Post by Pecunia » 2008-03-08T13:19:56-07:00

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?

User avatar
magick
Site Admin
Posts: 10995
Joined: 2003-05-31T11:32:55-07:00

Re: DDS support

Post by magick » 2008-03-08T13:39:20-07:00

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.

Post Reply