midora Posted March 28, 2021 Share Posted March 28, 2021 I checked my MeasureSelection and MeasureObject plugins (created 2014) and detected that the last one is no longer working correctly. As other object plugins MeasureObject expects that all surrounding pixels of an object use an alpha value of zero. The plugin creates a region containig all pixels of the object (I know it is not working fine if there is more than one object). startX/Y and endX/Y are the bounds of the source surface. _measureRegion = new PdnRegion(Rectangle.Empty); for (int y = startY; y < endY; y++) { for (int x = startX; x < endX; x++) { if (src[x, y].A != 0) { int xx = x; do { x++; } while ((x < endX) && (src[x, y].A != 0)); _measureRegion.Union(new Rectangle(xx, y, x - xx, 1)); } } } GetBoundsInt() now returns 0/0 for the top/left. I'm pretty sure this was not the case in 2014 😉 Maybe the problem is that Union does no longer ignore the Rectangle.Empty initialization of the PdnRegion. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted March 29, 2021 Share Posted March 29, 2021 What happens if you use regular Region instead of PdnRegion? PdnRegion is a thread-safe wrapper around Region. It may have some new caching bugs that I need to fix. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
midora Posted March 29, 2021 Author Share Posted March 29, 2021 I will do some more tests Rick. But as I remember there is no GetBoundsInt(). So one of the questions is why does pdnregion.GetBoundsInt() returns X/Y=0/0 but pdnregion.GetBounds() works fine. So for this issue I'm just rounding the values from the RectangleF to get a Rectangle. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted March 29, 2021 Share Posted March 29, 2021 Create the Region using the code you have above (but of course substituting Region for PdnRegion) Then create a new PdnRegion using the constructor that takes a Region. This will copy the Region and wrap it (remember, PdnRegion is just a wrapper around Region anyway, mostly for thread safety stuff) Then call the PdnRegion's GetBoundsInt() This is for troubleshooting purposes -- this will just tell me if there's a bug and along what code path it might be on. You shouldn't need to worry about this at all, PdnRegion should just work. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Rick Brewster Posted March 29, 2021 Share Posted March 29, 2021 Also if you can give me a list of the rectangles that you are union-ing, I can more easily test this out myself. Just a text file with each rectangle's ToString() on its own line is fine, you can paste it here into a code block Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
midora Posted March 30, 2021 Author Share Posted March 30, 2021 I will do this. Still I would check how it could happen that GetBoundsIn()t returns 0/0 for top/left compared to GetBounds() which seems to return the correct bounding rectangle always. I merged MeasureSelection and MeasureObject now to one because it makes not really sense to provide two separate plugins (guess I have to look for a solution to paste images here because of the limit). Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted March 30, 2021 Share Posted March 30, 2021 Yeah I'll look into it, I just need some test data Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
midora Posted March 30, 2021 Author Share Posted March 30, 2021 https://ibb.co/YQmNmBN (2021-03-30 Measure Selection.png) No idea how to show this image in the post. Maybe someone can provide a hint. Or is just possible for imgur? Anyway I like to add some remarks regarding the image - I have stolen the ruler icon of paint.net and added a selection. I hope this is OK 🙂 - I'm wondering why when creating a circle (while shift is pressed) sometimes a different width and height is visible in the status line. Rounding issue? - The area of the selection differs between paint.net and plugin. I expect the reason is that I can just count the pixels of the scan lines while paint.net can add fractions of a pixel Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted March 31, 2021 Share Posted March 31, 2021 3 hours ago, midora said: - I have stolen the ruler icon of paint.net and added a selection. I hope this is OK 🙂 I'm okay with it in this instance. In general, however, you can't do that -- the icons are not licensed for that, partly because I don't have the rights to give them away like that (many/most come via https://axialis.com). I made the ruler icon from scratch though, so I can do whatever I want with it. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
midora Posted March 31, 2021 Author Share Posted March 31, 2021 Fine that this has been clarified. By using the word 'stolen' it should be clear that I'm looking for the rights. The old icon just didn't fit to the new icons. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted March 31, 2021 Share Posted March 31, 2021 I think I figured out the bug here -- fix should be in next (well, first) build of 4.2.16 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.