Jump to content

OptionBasedLibrary Development


Recommended Posts

This topic is about OptionBasedLibrary an paint.net extension which allows developers to create an extended user interface for effect and filetype plugins. The standard plugin development uses paint.nets PropertyBased methods to setup the user interface and the communication with the main application. OptionBasedLibrary must be installed in the same folder as the paint.net application (not in the effects or filetype folder.

 

Here are some of the features of the OptionBasedLibrary:

  • Tab pages (this helps to structure the ui options and can help to avoid
  • tbfi

 

There will be a description and examples of how to use the library in the future.

 

If there are any questions or feature request then feel free to add them to this topic.

 

Warnings

  • Don't set PropertyBasedLook = true in an ConfigurationOfDialog instance. Worst case scenario: paint.net will crash.
Edited by midora
  • Like 1
midora%20signature.gif
Link to post
Share on other sites
2 hours ago, NSD said:

In the meantime, the problem was solved in PDN, but it remained in the OBL.

OK, I will check if I can reproduce this. Thanks for the hint.

 

PS: I stumbled over Reds Brexit comment in this topic 😉. I just like to say that the people in GB had no experience with grassroots democracy like in Switzerland. And the result is that you got a divided country splitted in winners and loosers. This is not democracy this is ochlocracy. Just my two cents. But this is not the right place to discuss.

Edited by midora
midora%20signature.gif
Link to post
Share on other sites
1 hour ago, Rick Brewster said:

Have you thought about hosting the source code on GitHub?

After some clean up there is in general no reason not to do it. In the moment I just have an idea what I did in OBL 😉

OK there is one reason I would like to discuss with you first.

midora%20signature.gif
Link to post
Share on other sites

In the meantime I'm able to build OBL and my Example plugin. Takes some time (after 5 years) to setup the build environment.

 

@NSDI tried to reproduce the issue with the DoubleSlider checking some of the OBL plugins published in the forum, but wasn't able to find an example where the issue happens. Could you point to a plugin and the  option?

 

midora%20signature.gif
Link to post
Share on other sites

I could reproduce and debug the issue using the same settings as in TextDistortion for a DoubleSlider in my ExamplePlugin.

Seems the issue was exactly the same as Rick mentioned. A cast to int of the Slidercontrol after multiplying with the 10^DecimalPlaces.

So this will be fixed in a futute version of OptionBasedLibrary.

  • Like 1
midora%20signature.gif
Link to post
Share on other sites

In the meantime Rick has introduced EffectOptions instead of EffectFlags with a number of features that are not recognized by OBL.
Maybe you can update this?

 

public EffectPlugin()
            : base(StaticName, StaticImage, SubmenuNames, new EffectOptions() { Flags = EffectFlags.Configurable, RenderingSchedule = EffectRenderingSchedule.None })
        {
        }

//Another Options:
EffectRenderingSchedule.DefaultTilesForCpuRendering
EffectRenderingSchedule.DefaultTilesForGpuRendering 
EffectRenderingSchedule.None
EffectRenderingSchedule.SmallHorizontalStrips
EffectRenderingSchedule.Tiles1024x1024
EffectRenderingSchedule.Tiles128x128
EffectRenderingSchedule.Tiles256x256
EffectRenderingSchedule.Tiles512x512

 

  • Like 1
Link to post
Share on other sites

Here are the docs for EffectRenderingSchedule, btw

public enum EffectRenderingSchedule
    : long
{
    /// <summary>
    /// The image is broken up into square tiles, the size of which is chosen automatically.
    /// Each call to Render() contains the scans for 1 tile.
    /// </summary>
    DefaultTilesForCpuRendering = -2,

    /// <summary>
    /// The image is broken up into square tiles, the size of which is chosen automatically.
    /// Each call to Render() contains the scans for 1 tile.
    /// </summary>
    DefaultTilesForGpuRendering = -1,

    /// <summary>
    /// The image is broken up into small horizontal strips that cover the full width up the image.
    /// </summary>
    /// <remarks>
    /// This is the "classic" rendering schedule up through version 4.0.21.
    /// </remarks>
    SmallHorizontalStrips = 0,

    /// <summary>
    /// There is only one call to the Effect's Render method, and all regions of interest are
    /// delivered at that time. This also means rendering is effectively single threaded.
    /// </summary>
    /// <remarks>
    /// This is the same behavior of the now-obsolete EffectFlags.SingleRenderCall.
    /// </remarks>
    None = 5,

    /// <summary>
    /// The image is broken up into 128x128 tiles.
    /// Each call to Render() contains the scans for 1 tile.
    /// </summary>
    /// <remarks>
    /// This generally works best for classic effects with the 4.0 rendering engine which is based on
    /// rendering 128x128 tiles. It is also appropriate for GPU/Direct2D effects on very small images.
    /// </remarks>
    Tiles128x128 = 0x1007,

    /// <summary>
    /// The image is broken up into 256x256 tiles.
    /// Each call to Render() contains the scans for 1 tile.
    /// </summary>
    /// <remarks>
    /// This is a good size for GPU/Direct2D effects on small-to-medium sized images.
    /// </remarks>
    Tiles256x256 = 0x1008,

    /// <summary>
    /// The image is broken up into 512x512 tiles.
    /// Each call to Render() contains the scans for 1 tile.
    /// </summary>
    /// <remarks>
    /// This is a good size for GPU/Direct2D effects on medium-to-large sized images.
    /// </remarks>
    Tiles512x512 = 0x1009,

    /// <summary>
    /// The image is broken up into 1024x1024 tiles.
    /// Each call to Render() contains the scans for 1 tile.
    /// </summary>
    /// <remarks>
    /// This is a good size for GPU/Direct2D effects on large-to-huge sized images.
    /// </remarks>
    Tiles1024x1024 = 0x100A,
}

 

  • Like 1

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

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

forumSig_bmwE60.jpg

Link to post
Share on other sites

@NSDIn a second step we may do this. In the moment OBL still references PDN 3.5.11 dlls.

But first I really like to recover as many of my plugins as possible using a single version of OBL (0.8?). Just to remember and figure out what I did there to get OBL to run. I have to setup git repositories for all the projects. This is not a one day job... 😉

  • Like 1
midora%20signature.gif
Link to post
Share on other sites

Made some progress in recovery of OBL and was able to support the theme setting in PDN.

As an example a screenshot of the 'Color Harmonies' plugin using the OBL in development.

 

image.png.8119357c0d68018927495cc431011df8.png

 

 

  • Like 3
  • Upvote 1
  • You're a Smart Cookie! 2
midora%20signature.gif
Link to post
Share on other sites

@Martin Osieka, when I try to use OptionDoubleVectorPan, it doesn't work correctly.  Can you provide some example code that demonstrates its proper usage?

 

bad_pan.png

 

Here's the code I'm using to test:

protected override OptionControlList OnSetupOptions(OptionContext optContext)
{
    return new OptionControlList
    {
        new OptionDoubleVectorPan(OptionNames.Position, optContext, 0.0, 0.0)
        {
            StaticBitmapUnderlay = new Bitmap(100, 100)
        }
    };
}

 

Link to post
Share on other sites

@toe_head2001Works fine for me with your parameters.

 

image.png.c5eb9aeedbedcc1a813fd0e3595efc71.png

If you just provide defaults for x and y then the default range is -1 to 1.

Not sure what's going wrong. Are you referencing OBL 0.7.9?

Maybe give

StaticBitmapUnderlay = this.EnvironmentParameters.SourceSurface.CreateAliasedBitmap()

a try. Just to see if it works with the current image.

 

 

 

midora%20signature.gif
Link to post
Share on other sites

Just a remark about different OBL versions.

In the moment plugins are using 6 different versions of OBL. So you are getting a mess in the paint.net folder if you are using plugins based on OBL.

For sure the goal was always to get OBL final regarding the basic interface and to remove the version number in the filename at this stage.

Means from this final release only features will be added but plugins should continue to work with newer OBL version.

midora%20signature.gif
Link to post
Share on other sites

OptionPanelPagesABC only allows to add multiple OptionPanelPage controls. Only one is active. The others are hidden or disabled depending on the variant ABC.

I do not remember exactly about OptionPanelPagesAsStackItems. I guess it was an experimental one and has not been finished. Or maybe lost in 2015.

OptionPanelPagesAsTabs is the typical example.

OptionPanelPagesAsStackItems should show just the title lines of the pages vertically. Only the active page shows the embedded option below of its title (I guess you know this from other application). Sometimes this more intuitive then AsTabs.

There are more variants in experimental state.

 

  • Like 1
midora%20signature.gif
Link to post
Share on other sites
10 hours ago, midora said:

Not sure what's going wrong. Are you referencing OBL 0.7.9?

 

Yes, version 0.7.9.

 

10 hours ago, midora said:

Maybe give

StaticBitmapUnderlay = this.EnvironmentParameters.SourceSurface.CreateAliasedBitmap()

a try. Just to see if it works with the current image.

 

Yeah, that's what I tried first.  It causes a crash:

 

Exception details:
System.ArgumentException: Parameter is not valid.
   at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
   at ControlExtensions.ControlPan.DrawToGraphics(Graphics g)
   at ControlExtensions.ControlPan.CheckRenderSurface()
   at ControlExtensions.ControlPan.DoPaint(Graphics g)
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
   at System.Windows.Forms.Control.WmEraseBkgnd(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.UserControl.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Link to post
Share on other sites

Maybe there is issue in OnLayout of OptionControlList and width and height are getting zero.

Did you test just with OptionDoubleVectorPan or a more complex OptionControlList?

 

midora%20signature.gif
Link to post
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...