ArgusMagnus Posted October 10, 2018 Share Posted October 10, 2018 (edited) Is there a Basic documentation/how to for writing FileType plugins? I've tried with the help of examples found online and based on the source of plugins like TinyPNG, but I cannot get PDN to Show me my plugin when I click "Save as...". This is what I have so far, any help would be appreciated. (It's a save-only plugin): public sealed class TestFileType : FileType, IFileTypeFactory { TestFileType() : base("Test", FileTypeFlags.SupportsSaving | FileTypeFlags.SavesWithProgress, new[] { ".test" }) { } protected override Document OnLoad(Stream input) { return null; } protected override void OnSave(Document input, Stream output, SaveConfigToken token, Surface surface, ProgressEventHandler callback) { // Do save operation... base.OnSave(input, output, token, surface, callback); } FileType[] IFileTypeFactory.GetFileTypeInstances() { return new[] { new TestFileType() }; } } Edited October 10, 2018 by ArgusMagnus Quote My batch Image Processor: https://imagenator.codeplex.com Link to comment Share on other sites More sharing options...
toe_head2001 Posted October 10, 2018 Share Posted October 10, 2018 3 minutes ago, ArgusMagnus said: public sealed class TestFileType : FileType, IFileTypeFactory I may be mistaken, but I believe your filetype class should not be inheriting from both FileType & IFileTypeFactory. You need to create a class for both of them. Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
null54 Posted October 10, 2018 Share Posted October 10, 2018 15 minutes ago, toe_head2001 said: I may be mistaken, but I believe your filetype class should not be inheriting from both FileType & IFileTypeFactory. You need to create a class for both of them. Inheriting from both FileType & IFileTypeFactory is fine, my WebP FileType does that for instance. The problem is that @ArgusMagnus is missing the public modifier on the constructor. public sealed class TestFileType : FileType, IFileTypeFactory { public TestFileType() : base("Test", FileTypeFlags.SupportsSaving | FileTypeFlags.SavesWithProgress, new[] { ".test" }) { } protected override Document OnLoad(Stream input) { return null; } protected override void OnSave(Document input, Stream output, SaveConfigToken token, Surface surface, ProgressEventHandler callback) { // Do save operation... base.OnSave(input, output, token, surface, callback); } FileType[] IFileTypeFactory.GetFileTypeInstances() { return new[] { new TestFileType() }; } } 1 Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait Link to comment Share on other sites More sharing options...
ArgusMagnus Posted October 10, 2018 Author Share Posted October 10, 2018 ah.. I feel stupid.. Thanks for the quick Responses! Quote My batch Image Processor: https://imagenator.codeplex.com Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.