Jump to content

Document properties?


r2d2rigo

Recommended Posts

I'm doing a filetype plugin and when I'm loading a file I want to store some custom internal data in the current document (like the existence of mipmaps or not) that will be properly parsed when re-saving. Is there any way to do this?

Link to comment
Share on other sites

Document has a Metadata property on it, which is a container for any type of metadata, organized by sections. Come up with a section name for your stuff, and toss whatever key/value pairs you want into it.

It also holds the EXIF metadata in a section named "$exif" (preferably, use Metadata.ExifSectionName instead of "$exif", or better yet use methods like GetExifValues(), RemoveExifValues(), ReplaceExifValues()).

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

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

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Also, each Layer has its own Metadata instance. So if you need to store per-layer metadata, prefer that instead of some encoding scheme on the document. It's been there since v2.5 (6 years), but I don't think anything (including Paint.NET) has used it yet. It will successfully persist, however.

Only EXIF metadata has a chance of being preserved when saving as a non-.PDN file type. Or, of course, if you save/load the Metadata, then your custom file type will do it. But JPG, PNG, etc. won't.

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

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

forumSig_bmwE60.jpg

Link to comment
Share on other sites

  • 2 weeks later...

Thank you, Rick! Now I have another question: is there any way I can access the document being saved from the funciton OnCreateSaveConfigUI? I want to give different default values to some of the properties, depending on the original ones readen from the loaded file and stored as document metadata. Is this possible?

Link to comment
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.

×
×
  • Create New...