Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when opening dds file #14

Closed
martinussuherman opened this issue Sep 22, 2021 · 5 comments
Closed

Error when opening dds file #14

martinussuherman opened this issue Sep 22, 2021 · 5 comments

Comments

@martinussuherman
Copy link

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
Copy link
Owner

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
Copy link
Author

martinussuherman commented Sep 23, 2021

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

Regards,

Martinus

0xC0000054 added a commit that referenced this issue Sep 12, 2023
This flag allows the plugin to load legacy DDS files where the header
specifies that there are more mipmaps than the image size allows.

Related to #14
@0xC0000054
Copy link
Owner

This has been fixed in version 1.12.4.

@xrSimpodin
Copy link

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
Copy link
Owner

@xrSimpodin I moved your post into its own issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants