0xC0000054 / pdn-ddsfiletype-plus

A Paint.NET filetype plugin that adds support for some of the DDS formats introduced in DirectX 10 and later.
https://forums.getpaint.net/topic/111731-dds-filetype-plus/
MIT License
69 stars 5 forks source link

Error when opening dds file #14

Closed martinussuherman closed 3 years ago

martinussuherman commented 3 years ago

I've got error when opening dds file, exception message below:

Application version: paint.net 4.2.10

System.ArgumentException: Value does not fall within the expected range.
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at DdsFileTypePlus.DdsNative.Load(Stream stream)
   at DdsFileTypePlus.DdsFile.Load(Stream input)
   at PaintDotNet.FileType.Load(Stream input) in D:\src\pdn\src\Data\FileType.cs:line 522
   at PaintDotNet.FileType.Load(Stream input) in D:\src\pdn\src\Data\FileType.cs:line 522
   at PaintDotNet.Functional.Func.Eval[T1,TRet](Func`2 f, T1 arg1) in D:\src\pdn\src\Base\Functional\Func.cs:line 158

This is the dds file (zipped): beam_lo.zip

Regards,

Martinus

0xC0000054 commented 3 years ago

That file contains an invalid number of mipmaps. The file header states that it has 10 mipmaps, when a 256x256 pixel image can only have 9. DirectXTex decodes every image when loading a file, so it is strict about validating the file header.

I fixed the file header with a hex editor, the zip file is attached below: beam_lo_fixed.zip

martinussuherman commented 3 years ago

Thanks for the help @0xC0000054. Looks like an off by one error in some of the dds file I've got.

Regards,

Martinus

0xC0000054 commented 1 year ago

This has been fixed in version 1.12.4.

xrSimpodin commented 1 year ago

Hello! I have a similar problem with textures from the game STALKER SHoC.

Exception:

System.FormatException: The DDS file is invalid.
   at DdsFileTypePlus.DdsNative.Load(Stream stream, DDSLoadInfo& info) in D:\Dev_projects\DdsFileTypePlus\src\DdsNative.cs:line 57
   at DdsFileTypePlus.DdsReader.Load(Stream input, IServiceProvider services) in D:\Dev_projects\DdsFileTypePlus\src\DdsReader.cs:line 30
   at PaintDotNet.FileType.Load(Stream input) in D:\src\pdn\src\Data\FileType.cs:line 491
   at PaintDotNet.Data.FileTypeProxy.OnLoad(Stream input) in D:\src\pdn\src\PaintDotNet\Data\FileTypeProxy.cs:line 60
   at PaintDotNet.FileType.Load(Stream input) in D:\src\pdn\src\Data\FileType.cs:line 491
   at PaintDotNet.Functional.Func.Eval[T1,TRet](Func`2 f, T1 arg1) in D:\src\pdn\src\Fundamentals\Functional\Func.cs:line 60

Diagnostics:

Application                                          paint.net версия 5.0.10 (Stable 5.10.8674.32967)
Build Date                                           1 октября 2023 г.
Install type                                         Classic

These textures are displayed in the game and opened in Photoshop: textures.zip

0xC0000054 commented 1 year ago

@xrSimpodin I moved your post into its own issue.