papasnewbag Posted June 2, 2011 Share Posted June 2, 2011 I was running my File Type plugin on a recent version of Paint.net and it wasn't working because the "ouput" param to OnSave() changed from type FileStream to GuardedStream (declared argument type is just Stream). For most of my code this is just fine, because there were no assumptions about it being a FileStream. But in particular there was one aspect that depended on FileStream.Name. My plugin takes all the layers of the PDN file and outputs them as separate files, while the primary export is a XML index file that contains metadata about those layers. It uses FileStream.Name to make sure that the exported layer files get put in the same place and with the same naming convention that was specified. Without that I don't know what else to do except use fixed paths (which is definitely undesirable and negates a lot of the value of the plugin). Is there a way to at least get the path that the file is meant to be saved to? I couldn't find any info here on GuardedStream. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted June 2, 2011 Share Posted June 2, 2011 You cannot assume that the Stream will be a FileStream. FileType plugins are only supposed to write data into the provided stream, and never anywhere else. It's not possible to do what you want without cheating and using Reflection, at which point you may not publish your plugin to the forum here. If that's not a concern, and you're just doing this for your own personal use, then use reflection to get at the private "source" field (of type Stream) in GuardedStream. Quote 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 More sharing options...
papasnewbag Posted June 2, 2011 Author Share Posted June 2, 2011 Thanks for the fast response! My plugin is just for personal use, so I'm not above using Reflection to just get unblocked. I'm a huge fan of paint.net, and because of that I've been using it as part of my asset tool chain. My plugin isn't really in its current state generally useful to people (since I imagine the exported xml file and modifications to the layers aren't what most people are looking for). Anyway, grabbing the private field with Reflection works, although it appears the behavior's different in that FileTime.Name is always reporting "[unknown]". Oh well, I can correct this with a script that runs after the plugin export. Let me know if you have a better idea of how to export PDN layers into individual files. I had always figured a plugin would be more managable than trying to figure out the PDN file format. Quote Link to comment Share on other sites More sharing options...
Simon Brown Posted June 2, 2011 Share Posted June 2, 2011 I'm not sure whether this is what you're looking for, but there's already a utility to export layers to individual files. Quote Link to comment Share on other sites More sharing options...
papasnewbag Posted June 3, 2011 Author Share Posted June 3, 2011 I'm not sure whether this is what you're looking for, but there's already a utility to export layers to individual files. Awesome! If the tweaks to my existing plugin don't work then I should be able to use the Layer Saver app with some post processing on the results to achieve the same result. Thanks for the link! 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.