WallyTheSapien Posted October 13 Share Posted October 13 I couldn't find out whether your able to create a new layer via a plugin and I would like to know how to if it is able to be done Quote Link to comment Share on other sites More sharing options...
null54 Posted October 13 Share Posted October 13 20 minutes ago, WallyTheSapien said: I couldn't find out whether your able to create a new layer via a plugin and I would like to know how to if it is able to be done Not possible, see https://forums.getpaint.net/topic/14566-what-is-and-isnt-possible-when-writing-plugins/. 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...
otuncelli Posted October 13 Share Posted October 13 37 minutes ago, WallyTheSapien said: I couldn't find out whether your able to create a new layer via a plugin and I would like to know how to if it is able to be done Only possible with file type plugins. Quote Link to comment Share on other sites More sharing options...
WallyTheSapien Posted October 13 Author Share Posted October 13 9 minutes ago, otuncelli said: Only possible with file type plugins. could you tell how how I would do that in a file type plugin like is there a function for it?? Quote Link to comment Share on other sites More sharing options...
Solution otuncelli Posted October 13 Solution Share Posted October 13 Sure. using PaintDotNet; ... ... // surface contains the pixel data Surface surface = new Surface(width, height, SurfaceCreationFlags.DoNotZeroFillHint); // add your surface to a layer BitmapLayer layer = new BitmapLayer(surface, takeOwnership: true) { Name = "Layer Name", Visible = true, BlendMode = LayerBlendMode.Normal, Opacity = 255 }; // then add the layer to a document Document document = new Document(width, height); document.Layers.Add(layer); 1 Quote Link to comment Share on other sites More sharing options...
Tactilis Posted October 13 Share Posted October 13 3 hours ago, WallyTheSapien said: I couldn't find out whether your able to create a new layer via a plugin and I would like to know how to if it is able to be done What are you actually trying to achieve with your plugin that would require the creation of a new layer? If you explain the context, then people may be able offer you a solution in a different way. Quote Link to comment Share on other sites More sharing options...
WallyTheSapien Posted October 13 Author Share Posted October 13 14 hours ago, Tactilis said: What are you actually trying to achieve with your plugin that would require the creation of a new layer? If you explain the context, then people may be able offer you a solution in a different way. so I'm trying to make a plugin that splits an height map into deferent layers depending on the height Quote Link to comment Share on other sites More sharing options...
WallyTheSapien Posted October 13 Author Share Posted October 13 I would also want to know how to export the layers as separate files in like a zip file Quote Link to comment Share on other sites More sharing options...
WallyTheSapien Posted October 13 Author Share Posted October 13 17 hours ago, otuncelli said: Sure. using PaintDotNet; ... ... // surface contains the pixel data Surface surface = new Surface(width, height, SurfaceCreationFlags.DoNotZeroFillHint); // add your surface to a layer BitmapLayer layer = new BitmapLayer(surface, takeOwnership: true) { Name = "Layer Name", Visible = true, BlendMode = LayerBlendMode.Normal, Opacity = 255 }; // then add the layer to a document Document document = new Document(width, height); document.Layers.Add(layer); I'm trying to add this to my file type plugin but I can't figure out how to add it too it correctly Quote Link to comment Share on other sites More sharing options...
BoltBait Posted October 13 Share Posted October 13 32 minutes ago, WallyTheSapien said: I would also want to know how to export the layers as separate files in like a zip file This already exists: https://forums.getpaint.net/topic/31996-zip-archive-filetype-plugin-zip-latest-v14-2021-11-04/ Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
otuncelli Posted October 14 Share Posted October 14 (edited) You need to derive your plugin class from FileType or PropertyBasedFileType or FileType<TToken, TTWidget> and implement IFileTypeFactory or IFileTypeFactory2 (newer, recommended) interfaces. Derive from FileType if you don't need to show any settings on Save dialog, Derive from PropertyBasedFileType if you need to show settings on Save dialog using paint.net's internal controls, aka "IndirectUI", Derive from FileType<TToken, TTWidget> if you need to show settings on Save dialog using your own controls You need to implement your own dialog and controls if you need to show settings when opening a file (in OnLoad method). This isn't something supported officially but possible. A very simple implementation that derives from FileType: https://github.com/PsdPlugin/PsdPlugin/blob/master/PhotoShopFileType/PhotoshopFileType.cs The code I've posted should go into the Document OnLoad(System.IO.Stream input) method. You create the document using the input stream, return it and then paint.net opens it. Also @null54 has lots of open source file type plugins. They helped me a lot when learning stuff. https://github.com/0xC0000054?tab=repositories&q=paint.net+filetype Edited October 14 by otuncelli Quote 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.