Jump to content

Configuring save options for FileTypes retrieved from IFileTypesService


null54

Recommended Posts

I am working on converting my Optimized JPEG FileType to PDN 5.

 

I was hoping to be able to use the built-in JPEG FileType for saving, but I could not see any was to programmatically configure its quality setting.

 

PdnSig.png

Plugin Pack | PSFilterPdn | Content Aware Fill | G'MICPaint 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

There isn't really any publicly accessible way to use the built-in FileTypes for saving. I'm guessing you want to use the built-in JPEG FileType because it knows how to deal with WIC and all of its sharp corners.

 

I'm planning a big revamp of File Types stuff in PDN 6.0, but that's still quite a ways off. In the meantime I'm extremely hesitant to add pretty much anything to the FileType class, because part of the revamping will be replacing it with an interface-based API. 

 

However, instead of general purpose APIs (e.g. FileType), it might be reasonable to put in a special purpose interface for this sort of thing, e.g.

 

public interface IJpegService
{
    IJpegSaveOptions CreateSaveOptions();
  
    void Save(
      Stream output,
      IBitmapSource bitmap,
      IJpegSaveOptions options,      
      CancellationToken cancelToken);
}

public interface IJpegSaveOptions
{
    int Quality { get; set; }
    ...
    ... some properties for metadata, color context, etc.
}

 

This is doable now, and also provides an interface that is supportable after the FileTypes revamp, even if it does essentially get superceded by some kind of general purpose API.

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

4 minutes ago, Rick Brewster said:

I'm guessing you want to use the built-in JPEG FileType because it knows how to deal with WIC and all of its sharp corners.

 

That is correct. Mainly for the fact that it handles all of the metadata support, which would be a pain to re-implement using WIC.

I considered casting the token returned by CreateDefaultSaveConfigToken to PropertyBasedSaveConfigToken, but that is a bit of a hack.

 

19 minutes ago, Rick Brewster said:

However, instead of general purpose APIs (e.g. FileType), it might be reasonable to put in a special purpose interface for this sort of thing, e.g.

 

That would work.

PdnSig.png

Plugin Pack | PSFilterPdn | Content Aware Fill | G'MICPaint 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

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