Jump to content

How are Tools Effects implemented?


midora

Recommended Posts

So I'm talking about effects which do not change the destination surface (like Printer+).

 

Do they intercept the render function to show their dialog (because I can see the progress bar once while the dialog opens). Or is there an other way to integrate them as effect. What would be the parent of a dialog? Some example code would be fine.

 

In the moment I would add to the Render function.

 

- copy of source to dest surface (necessary?)

- calling of the tools functionality (open dialog, ...)

- calling of SignalCancelRequest() (this function looks like it could cancel the rendering)

 

The reason is to implement a printing functionality which respects DPI settings of the image.

midoras signature.gif

Link to comment
Share on other sites

In your config dialog, set the DialogResult to Cancel before closing. Printer+ just "pretends" that it was cancelled, so no rendering happens. This is exactly the same as what happens if you press Cancel on a regular effect.

 

 

The reason is to implement a printing functionality which respects DPI settings of the image.

 

I'm pretty sure that won't be possible because the DPI information isn't available from the layer. Effects only get 1 layer's bitmap, not the actual layer and certainly not access to the whole image ("Document").

 

Also, here's a tip: if you find yourself asking "how is X implemented", just boot up your copy of Reflector (or ILSpy or whatever) and look at the disassembly :)

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

I'm pretty sure that won't be possible because the DPI information isn't available from the layer. Effects only get 1 layer's bitmap, not the actual layer and certainly not access to the whole image ("Document").

 

I know this and I guess I already asked once to provide the DPI information and unit in the environment.

 

Because of this issue 'Paper Models' plugin allows you to set 'unit and dpi' in the config dialog (and there is a hint in the property description entry telling you to set the value of the image). Not so nice for the user but I know you would not be happy if a plugin would use the dirty way to access the document values ;-)

 

In general I'm a little bit tired to use reassembly tools to get informations. This is not the kind of documentation I like to use.

midoras signature.gif

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