Joshua Lamusga

What's next for brush factory?

Recommended Posts

@Joshua Lamusga

 

Another pull request and a few questions.

 

Override the On* methods instead of using event handlers

 

I was thinking of moving the settings into a separate class to allow for storing more general settings, such as the last folder in the add brush dialog.

Should the plugin store settings in the Paint.NET user files folder instead of the registry when Paint.NET is in portable mode?

 

I have also been considering changing the "Add Folder" button in the preferences dialog to use the Vista-style folder browser, basically an Explorer open file dialog that can select folders.

This would require adding a large amount of COM interop code, and even though this dialog is more user friendly I am not sure that users would browse for a folder often enough to make it worth the amount of code needed to implement it.

Share this post


Link to post
Share on other sites

I want to support portable mode, so it's a good idea to store in an .ini file or something. I don't think the add folder change will be necessary due to infrequent use, like you say. Thanks again for taking an interest.

Share this post


Link to post
Share on other sites
3 hours ago, Joshua Lamusga said:

I want to support portable mode, so it's a good idea to store in an .ini file or something.

 

My plan is to convert the registry settings to an XML file stored in the Paint.NET user files folder.

This would allow the settings to be represented by a strongly-typed class, while letting the .NET Framework handle the conversion to/from XML.

 

 

Share this post


Link to post
Share on other sites

Not sure if this is a glitch guys or a dodgy mouse my side but:

Other >>> Select Rotate with mouse option >>> Drag and draw is fine.  Just a left click and it's sporadic when it chooses to draw. 25 clicks is the most I've done before it drew/rendered

 

Video

 

Share this post


Link to post
Share on other sites
3 hours ago, Joshua Lamusga said:

XML is fine.

 

Here is the pull request: Save the settings to a file instead of the registry

 

I would have also submitted the ListView code, but it has conflicting changes.

 

37 minutes ago, welshblue said:

Not sure if this is a glitch guys or a dodgy mouse my side but:

Other >>> Select Rotate with mouse option >>> Drag and draw is fine.  Just a left click and it's sporadic when it chooses to draw. 25 clicks is the most I've done before it drew/rendered

 

I have not modified any of the drawing code, so I have no idea what could be causing that. ?

Share this post


Link to post
Share on other sites
6 hours ago, Joshua Lamusga said:

XML is fine.

Have you considered JSON?  (I'm a recent JSON convert - so I'd quite like to know why if you choose to stick with XML)

Share this post


Link to post
Share on other sites

Awesome for performing migration of stuff from registry, @null54. I was going to add that if you hadn't.

 

Quote

Not sure if this is a glitch guys or a dodgy mouse my side

You discovered a design choice, actually. I need two points to determine the direction to make the image face, and since I don't track the previous mouse position until you start drawing, I only have one point. In experiments where I did track previous mouse position at all times, I discovered I'd get some bad results because there was almost no space between the two points because I slow down a lot when I start drawing the line. Reducing space between the two points has the interesting effect of reducing the accuracy of the direction of the image, so it was frequently pointed in the wrong direction (slightly, or sometimes substantially).

 

image.png.6768841f83122f5b26af0fd6807b2e30.png

Share this post


Link to post
Share on other sites
12 hours ago, Ego Eram Reputo said:

Have you considered JSON?  (I'm a recent JSON convert - so I'd quite like to know why if you choose to stick with XML)

 

As mentioned above I am using the serialization that is built-in to the .NET Framework, and XML is what the DataContractSerializer uses.

Share this post


Link to post
Share on other sites
13 hours ago, Joshua Lamusga said:

You discovered a design choice

 

A not so exciting Easter Egg find ?

 

Makes sense ... and lets face it how many loons are going to sit there just clicking apart from one ...

Share this post


Link to post
Share on other sites
8 hours ago, welshblue said:

 

A not so exciting Easter Egg find ?

 

Makes sense ... and lets face it how many loons are going to sit there just clicking apart from one ...

 

Two?

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, LionsDragon said:

Two?

Turn off rotate with mouse (which is off by default), and you can click around without problems. Just clarifying in case you weren't aware and for silent readers.

@null54 I pulled your changes, but I got some interesting errors:

 

1. When settings were moved, my .xml file ended with "settings>ings>" which caused it to crash, We should try...catch and regenerate the file if it fails to de/serialize.

2. Default brushes only load on subsequent runs.

3. On subsequent runs, custom brushes are appended to the first run's brushes, so it's custom brushesdefaultcustom brushes. No change observed with further runs.

4. The brush I had selected in a previous run is selected, but as brushes load in, the selected brush changes to the last one.

 

All errors reproduced within two consecutive runs and are fully reproducible. Both folder paths are included in my .xml file, so I'll share all those contents in a .zip for you to try and reproduce.

 

Non-reproducible error:

- The brushes failed to load after deleting a folder that's listed in custom brushes at one point; clicking crashed because I didn't have a valid bitmap, but I couldn't reproduce the error.

 

Other things I noticed:

- Since the brush icon I made was for the list view, I created a 24x24 one that should fit the size of the button. Haven't committed it anywhere yet.

- Your changes to the inherited RenderArgs code and undo/redo fixed the long-standing transparency bug for the most part; drawing is still a problem. If you can find the fix for that, I'll be pretty happy.

  • Like 1

Share this post


Link to post
Share on other sites
16 hours ago, Joshua Lamusga said:

1. When settings were moved, my .xml file ended with "settings>ings>" which caused it to crash, We should try...catch and regenerate the file if it fails to de/serialize.

 

Fixed: Use FileMode.Create when writing the settings

 

16 hours ago, Joshua Lamusga said:

2. Default brushes only load on subsequent runs.

3. On subsequent runs, custom brushes are appended to the first run's brushes, so it's custom brushesdefaultcustom brushes. No change observed with further runs.

4. The brush I had selected in a previous run is selected, but as brushes load in, the selected brush changes to the last one.

 

Another pull request: Fix the default brush loading

 

16 hours ago, Joshua Lamusga said:

- Your changes to the inherited RenderArgs code and undo/redo fixed the long-standing transparency bug for the most part; drawing is still a problem. If you can find the fix for that, I'll be pretty happy. 

 

After reading the linked thread I am wondering if GDI+ may be converting the 32bppARGB images to 32bppPARGB as part of its internal processing.

This would make sense if it is calling any GDI functions because 32bppPARGB is the only 32-bit alpha channel format that GDI supports.

 

It also appears to be fairly well documented that GDI+ performs best when it is using 32bppPARGB, a few links below as examples.

This could indicate some kind of format conversion is being skipped.

 

https://richorama.github.io/2016/08/10/image-interpolation-benchmarks/

https://www.gamedev.net/forums/topic/467752-maximizing-gdi-speed/

https://microsoft.public.dotnet.framework.drawing.narkive.com/Pb9bQRzv/great-speed-improvement-trick-format32bpppargb

Share this post


Link to post
Share on other sites

Thanks for fixing those bugs, Null54. There are a couple more since I git pulled:

 

1. In subsequent runs, if I have moved or deleted a folder from the custom brush locations that had successfully loaded on the first run, it will crash with DirectoryNotFoundException.

 

2. It seems that it no longer loads .abr files.

Edited by Joshua Lamusga

Share this post


Link to post
Share on other sites
1 hour ago, Joshua Lamusga said:

1. In subsequent runs, if I have moved or deleted a folder from the custom brush locations that had successfully loaded on the first run, it will crash with DirectoryNotFoundException. 

 
55 minutes ago, Joshua Lamusga said:

2. It seems that it no longer loads .abr files. 

 

I am not able to reproduce that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now