Rick Brewster

Fixed copy of Midora's ImAGIF FileType plugin (v0.13)

Recommended Posts

Midora seems to have abandoned the plugin and @Pixey's been unable to reach him. This plugin doesn't work in Paint.NET 4.2 because it's using a class that's now internal. The plugin shouldn't have been doing that, and I'm not going to change my code to accommodate it.

 

So, I disassembled it, fixed the build errors, and fixed up all (hopefully) the pointer code that Reflector bungled, and here we go.

 

Please try this out and let me know if you run into any problems. If it all works out then @Ego Eram Reputo can update the original plugin page with this version.

ImAGIF.FileType v0.13.zip

 

Here's the plugin's actual post/page: 

 

  • Upvote 1

Share this post


Link to post
Share on other sites
Spoiler

Application version: paint.net 4.2

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at PaintDotNet.Data.Quantize.Quantizer.ReplacePassWithDithering(BitmapData in32Data, List`1 lc, Int32 width, Int32 height, Int32 ditherLevel, ProgressEventHandler progressCallback) in C:\src\github\ImAGIF.FileType\PaintDotNet\Data\Quantize\Quantizer.cs:line 418
   at PropertyBasedFileTypes.ImAgifFileType.DoSave(Document input, Stream output, PropertyBasedSaveConfigToken token, Surface scratchSurface, ProgressEventHandler progressCallback) in C:\src\github\ImAGIF.FileType\PropertyBasedFileTypes\ImAgifFileType.cs:line 275
   at PropertyBasedFileTypes.ImAgifFileType.OnSaveT(Document input, Stream output, PropertyBasedSaveConfigToken token, Surface scratchSurface, ProgressEventHandler progressCallback) in C:\src\github\ImAGIF.FileType\PropertyBasedFileTypes\ImAgifFileType.cs:line 542
   at PaintDotNet.FileType.Save(Document input, Stream output, SaveConfigToken token, Surface scratchSurface, ProgressEventHandler callback, Boolean rememberToken) in D:\src\pdn\src\Data\FileType.cs:line 276
   at PaintDotNet.Dialogs.SaveConfigDialog.<>c__DisplayClass48_0.<UpdatePreviewAsync>b__0() in D:\src\pdn\src\PaintDotNet\Dialogs\SaveConfigDialog.cs:line 604
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PaintDotNet.Dialogs.SaveConfigDialog.<UpdatePreviewAsync>d__48.MoveNext() in D:\src\pdn\src\PaintDotNet\Dialogs\SaveConfigDialog.cs:line 623

 

The file I was attempting to save (attached) had one hidden layer. Deleting this layer allowed the file to save without error.

ActiveLayerDemo.zip

Share this post


Link to post
Share on other sites

Okay well, I've already put a ton of time into this and I have to move on.

 

Happy to open up the GitHub repo to anyone else if they're motivated to fix up any leftover bugs, but I can't spend any more time on this.

 

@null54? @Bruce Bowyer-Smyth? @BoltBait?

 

dnspy may be a better choice for disassembling the code. Reflector may have just garbled too much of it.

Share this post


Link to post
Share on other sites

I just tried it out in 4.2 and all is well:

 

semi-colon-and-space.gif

 

So now can I attach the new/fixed version into Midora's thread ?

  • Like 1

Share this post


Link to post
Share on other sites

No, not yet. @Ego Eram Reputo still has a bug with the image he was trying above ^^^

 

Could be worth making a thread in the Plugin Developer Central though. At least we can provide people with a beta.

Share this post


Link to post
Share on other sites
9 hours ago, Rick Brewster said:

Could be worth making a thread in the Plugin Developer Central though. At least we can provide people with a beta.

 

Can I move this thread?

Share this post


Link to post
Share on other sites
1 hour ago, toe_head2001 said:

Is anyone already working on this?

 

I'm not.

 

I'm no FileType expert.  (In fact, I'm not even a FileType beginner.)

Share this post


Link to post
Share on other sites
2 hours ago, toe_head2001 said:

Is anyone already working on this? If not, I'm willing to take a look.

 

It's on GitHub, you should now have access. If not let me know.

  • Like 1

Share this post


Link to post
Share on other sites

I simply told the plugin to skip over invisible Layers.

if (layers[i] is Layer layer && !layer.Visible)
{
    continue;
}

Seems to work around the issue that I don't completely understand.

 

Or is this plugin supposed to do something special with invisible layers? (I haven't used this plugin enough to know its "ins and outs") @Pixey , @Ego Eram Reputo, et al?

 

EDIT: this doesn't fully solve the issue.

 

Edited by toe_head2001
  • Like 1
  • Upvote 3

Share this post


Link to post
Share on other sites

I will test it tomorrow @toe_head2001 I have family staying and it's a bit hectic today.

 

As for invisible layers, as far as I can remember, if you did that you would just get an uneven rhythm in the finished .gif, -  like a flash.

 

 

Share this post


Link to post
Share on other sites

I just tested this @toe_head2001.  I don't have any problems with Rick's version, that I could see. I used a pdn file from the example folder.

 

However, your version does not work unless all the layers are ticked.  I can build a working gif with the pdn file with some layers turned 'off' in Rick's version.

 

agif_plugin.png

 

Notice nine (9) layers are unchecked. The gif builds just fine, leaving the layers 'as is'.

 

With yours, the unchecked layers get skipped over. The gif still 'builds', but it isn't animated.  I had to 'check' all the layers to get the gif to build correctly.

 

If you have a lot of layers, it would be a pain to tick them all.  Just letting you know....:)

 

EDIT: And I honestly don't know what is going on with EER's example. I can't find a hidden layer. If all of them are checked, it still doesn't build.

 

 

Edited by lynxster4
  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, lynxster4 said:

The gif still 'builds', but it isn't animated.  I had to 'check' all the layers to get the gif to build correctly.

 

You shouldn't need to check all layers; you just to check at least two frame layers. You have only one checked. Foreground and background don't count as frames.

 

1 hour ago, lynxster4 said:

If you have a lot of layers, it would be a pain to tick them all.  Just letting you know....:)

 

Ok, that's a fair point.

Share this post


Link to post
Share on other sites

Ok, I've taken a further look at this, and the issue is not dependent on later visibility.  Still working on it.

Share this post


Link to post
Share on other sites
14 minutes ago, Seerose said:

I have difficulties to understand. What about the layers?  

 

The issue with the layers has been resolved. There's no need to be concerned about it.

 

You just need to confirm the plugin works normally and without issues.

Share this post


Link to post
Share on other sites
10 hours ago, toe_head2001 said:

Ok, this reverts the layer visibility change, and should fix the issue found by @Ego Eram Reputo. Please confirm.

 

ImAGIF.FileType-Test2.zip 499.04 kB · 3 downloads

 

 

This version is includes hidden layers in the animation. In the attached file there is a path layer and a black layer which were both hidden.

 

At least it completes the save :)

 

ActiveLayerDemo3.gif

Share this post


Link to post
Share on other sites

Maybe there needs to be an option:

 

[X] Include hidden layers

Share this post


Link to post
Share on other sites

Join the conversation

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

Guest
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.