Problem with .DDS Files

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Caliginous

Problem with .DDS Files

Post by Caliginous »

Hello,

I'm trying to read in some DDS files to do some comparisons on them, and I'm running into some trouble. If I try something as simple as:

Code: Select all

identify -format '%k' DefaultNormal_256x256.dds
I get the error:

Code: Select all

identify: Improper image header 'DefaultNormal_256x256.dds'.
The image in question can be found here: http://www.gamers-fix.com/DefaultNormal_256x256.zip

I'm using ImageMagick version 6.4.2 07/13/08 Q16 on Windows XP Pro SP1, DLL distribution.

Thanks!
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Problem with .DDS Files

Post by Bonzo »

I do not think dds files are supported by Imagemagick. See:
http://www.imagemagick.org/script/formats.php
Caliginous

Re: Problem with .DDS Files

Post by Caliginous »

From: http://www.imagemagick.org/script/changelog.php

<clip>
2008-02-29 6.3.9-2 Cristy <quetzlzacatenango@image...>
* Add support for the Postable Document Archive Format.
* Add support for Braille images.
* Add support for DDS images (contributed by Bianca van Schaik).
* Add GetImageAlphaChannel() method.
* PSD clipping paths are once again recognized.
</clip>

The changelog as well as some other posts on the forum suggest that ImageMagick is capable of reading DDS files...
Perhaps it is broken?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Problem with .DDS Files

Post by Bonzo »

Looks like the documentation is a bit behind.

I can not open the image with 6.4.0 so there may be a problem. It opens OK with GIMP after I installed a plugin.
Caliginous

Re: Problem with .DDS Files

Post by Caliginous »

I just downloaded the source to try building from source and debugging it, and nt-base.c is all kinds of broken. Two symbols that are unknown (magick_off_t and MAP_ANON), as well as some syntax errors (. in a variable declaration list).

I think I have hacked around the compile errors, but even the compiled code has the same problem. I'm trying to step through the code now to see why it might be falling down.
Caliginous

Re: Problem with .DDS Files

Post by Caliginous »

Ok, stepping into the code, the DDSD_CAPS flag isn't set on my image's flags, and the DDS reader expects it to be set. I'm not exactly sure why the reader needs it, nor am I sure how I go about getting the flag set on my image.
Caliginous

Re: Problem with .DDS Files

Post by Caliginous »

Ok, I commented out the check against the DDSD_CAPS flag, and now ImageMagick can read my DDS file.

The change I made is here:

Was:

Code: Select all

	/* Check required flags */
	required = (unsigned long) (DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT);
  if ((dds_info->flags & required) != required)
		return MagickFalse;
Now:

Code: Select all

	/* Check required flags */
	required = (unsigned long) (DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT);
  if ((dds_info->flags & required) != required)
		return MagickFalse;
I'm not entirely sure why the CAPs structure was being looked for, as from what I can tell, the code manages just fine if the flag isn't set (and the structure isn't there).
Post Reply