Jump to content

error opening a file with wrong ext

Recommended Posts

When opening a JPEG file that is intentionally misnamed as a .bmp, as of Paint.net 4.2, it gives this error:


"Application version: paint.net 4.2

PaintDotNet.Imaging.UnknownImageFormatException (0x88982F07): D:\src\pdn\src\SystemLayer.Native\Imaging\WICImagingFactory.cpp (892) : hr = spDecoder->Initialize( spStream, static_cast<WICDecodeOptions>(metadataOptions));
   at PaintDotNet.Interop.InteropErrorInfo.ThrowIfError() in D:\src\pdn\src\Base\Interop\InteropErrorInfo.cs:line 98
   at PaintDotNet.SystemLayer.Native.x64.NativeUtilities.ThrowOnErrorImpl(Int32 hr, SByte* szHr, IUnknown* pFxErrorInfo)
   at PaintDotNet.SystemLayer.Native.x64.Imaging.WICImagingFactory.CreateDecoderFromStream(Stream stream, BitmapDecodeOptions metadataOptions, Nullable`1 containerFormat, Nullable`1 preferredVendor)
   at PaintDotNet.Data.WicFileTypeHelpers.Load(Stream input, Nullable`1 forcedContainerFormat, Nullable`1 preferredVendor, MetadataTranscoder metadataTranscoder) in D:\src\pdn\src\PaintDotNet\Data\WicFileTypeHelpers.cs:line 61
   at PaintDotNet.Data.BmpFileType.OnLoad(Stream input) in D:\src\pdn\src\PaintDotNet\Data\BmpFileType.cs:line 93
   at PaintDotNet.FileType.Load(Stream input) in D:\src\pdn\src\Data\FileType.cs:line 482
   at PaintDotNet.Functional.Func.Eval[T1,TRet](Func`2 f, T1 arg1) in D:\src\pdn\src\Base\Functional\Func.cs:line 158"


I believe (but not sure) that in previous versions, it would open the file without complaint or (apparent) issue.

Edited by McHildinger
Link to comment
Share on other sites

Whether or not Paint.NET opened this type of misnamed file in the past, changes required for new features causes Paint.NET to no longer open them.


The simple solution is to properly name your files before trying to open them.  If you need help identifying what the proper extension should be, try this plugin: https://forums.getpaint.net/topic/31715-whats-it-tools-effect-plugin/


I would not expect Rick to "fix" this problem.  EDIT: I was wrong...


Click to play:
Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game

Link to comment
Share on other sites

If it's a bmp then it should have the .bmp extension ... not .jpg


This was essentially a bug in older versions, an accidental features due to the way GDI+ was gracious about things. The file type system in PDN isn't set up to identify files and parse them regardless of the extension.


However, my intention with 4.2 was to preserve this behavior, even if I didn't really like it. GDI+ is a wrapper around WIC, but now PDN is using WIC directly, and WIC does support this behavior. 


When you* open an image with WIC you can tell it to force a specific container format (e.g. BMP, PNG, ...) or you can say "just figure it out". And it looks like I missed a spot and PDN's BmpFileType is say "only use BMP" instead of "just figure it out". I'll fix this for 4.2.1, it's easy.


* as in "the developer writing the code"

  • Like 1

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html


Link to comment
Share on other sites

I wouldn't "blame" Microsoft. They implemented it this way intentionally. In code, when you open an image with WIC you give it a "stream," not a file name. It doesn't even know the file extension of what you're working with. It must be able to detect the image type, usually from the first few bytes, and route the request to the given decoder.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html


Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...