Magick.net: Doesn't support DXTn raw data.

Created on 15 Jan 2019  Â·  8Comments  Â·  Source: dlemstra/Magick.NET

Prerequisites

  • [x] I have written a descriptive issue title
  • [x] I have verified that I am using the latest version of Magick.NET
  • [x] I have searched open and closed issues to ensure it has not already been reported

Description


This is a great project, but it seems to be an error when exporting images in DXTn format. The DDS format works fine, but it might be better to get DXTn raw data.

Steps to Reproduce


using (MagickImage image = new MagickImage("1.jpg"))
{
image.Format = MagickFormat.Dxt1;
var bytes = image.ToByteArray();
}

System Configuration

  • Magick.NET version:
    Magick.NET-Q8-x64.7.10.1
  • Environment (Operating system, version and so on):
    Windows 7, Visual Studio 2017,.Net Core 2.2
  • Additional information:
bug

All 8 comments

It appears that you found a bug and I just pushed a patch to the ImageMagick repository to resolve this. I will try to publish a new release this weekend to resolve this.

I tried to add some unit tests but I could not get them to fail. After a while I realized this was happening because another method call was made. And that means you could use the following as a temporary work around:
C# MagickNET.GetFormatInformation(MagickFormat.Dxt1);

Thank you for your work, I tried it as you said, there is really no error, but it returns the data in DDS format.

Can you clarify what you mean? Dxt1 and Dxt5 are compression method. Do you want the image without the dds header?

Yes, I use it in Unity3d, there is a method to load DXTn raw data directly to load the image quickly.
Public void LoadRawTextureData(byte [] data);
Public void LoadRawTextureData(IntPtr data,int size);
Of course, I can remove the header myself, but from a performance perspective, it might be better if I never generate a header.

Just like MagickFormat.Rgb.

I think it might be possible to add an option for this to the DDS encoder. Will try to take a look at it this weekend.

The new release that includes a fix for the DXT1/5 issue has been published. And this new release also adds an extra property Raw to the DdsWriteDefines class that can be used as an argument for the ToByteArray method. When you enable that option only the raw pixel data will be written to the output array.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cssriraman picture cssriraman  Â·  7Comments

zygimantaskazlauskas picture zygimantaskazlauskas  Â·  3Comments

trong8820 picture trong8820  Â·  8Comments

jayantrajwani picture jayantrajwani  Â·  9Comments

tttrrryyyyeer picture tttrrryyyyeer  Â·  6Comments