Bruce Bowyer-Smyth Posted April 8, 2013 Share Posted April 8, 2013 If you create a larger sized image, say 5000x4000 the selection rectangles that are passed to plugins have an incorrect width. In this case a width of 4999. The width difference seems to vary with image sizes. 4800x6400 gets a width of 4798. Win8, PDN 3.5.10 Quote GPU Blur Plugin | WMF File Plugin Link to comment Share on other sites More sharing options...
midora Posted April 8, 2013 Share Posted April 8, 2013 Could not verify this on Win7. Used the 'Measure Selection' plugin to look for the values. Which properties are you reading? Quote Link to comment Share on other sites More sharing options...
Bruce Bowyer-Smyth Posted April 8, 2013 Author Share Posted April 8, 2013 This is just the Rectange[] rois passed into the Render. I was pretty sure this used to work when I was on Win7. Possible problem under Win8. Quote GPU Blur Plugin | WMF File Plugin Link to comment Share on other sites More sharing options...
BoltBait Posted April 8, 2013 Share Posted April 8, 2013 Are you sure you didn't make the mistake of thinking the rectangle array was 1 based instead of 0 based? Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
Bruce Bowyer-Smyth Posted April 8, 2013 Author Share Posted April 8, 2013 Just using the startIndex and length that are passed in. Even so there is never more than one Rectangle at a time. On the larger images this is never true: roi.Right == base.SrcArgs.Width. Which it is with the smaller images. Quote GPU Blur Plugin | WMF File Plugin Link to comment Share on other sites More sharing options...
BoltBait Posted April 8, 2013 Share Posted April 8, 2013 Why would you assume that "roi.Right == base.SrcArgs.Width"? This is never guaranteed. You only know that your render function is fed a list of rectangles that covers the entire selected area. No promise is made that you'll receive a specific number of ROI's or that ROI's will be a specific size. The only thing you know for sure is that if you combine them all together they will completely cover the selected region. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
Bruce Bowyer-Smyth Posted April 9, 2013 Author Share Posted April 9, 2013 Didn't assume it. Only used it for testing. With a full image selected I never received a roi that went to the edge. Quote GPU Blur Plugin | WMF File Plugin Link to comment Share on other sites More sharing options...
BoltBait Posted April 9, 2013 Share Posted April 9, 2013 The width of a selection will never equal the index of a zero based array. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
Bruce Bowyer-Smyth Posted April 9, 2013 Author Share Posted April 9, 2013 You are right. It is the small sizes that were the problem. It appears to be known issue with the Rectangle struct. var r = new Rectangle(0, 0, 100, 10); Gives r.Right = 100 and r.Bottom = 10 when they should be 99 and 9. Nothing wrong with Paint.NET, cheers. Quote GPU Blur Plugin | WMF File Plugin Link to comment Share on other sites More sharing options...
Bruce Bowyer-Smyth Posted April 9, 2013 Author Share Posted April 9, 2013 No sorry there is still an issue. Rectangle.Right is defined as "The value of the Right property represents the x-coordinate of the first point at the right edge of the rectangle that is not contained in the rectangle". So Right will equal Width when Left = 0. At some point Paint.NET is passing in Rectangles that do not reach the width as in the 4800 to 4798 above. There are also no additional rois passed in that will cover the gap in the width. Mentioned above I was sure this didn't used to be a problem on my old Win7 box. Quote GPU Blur Plugin | WMF File Plugin Link to comment Share on other sites More sharing options...
BoltBait Posted April 9, 2013 Share Posted April 9, 2013 Can you test with a CodeLab script like this: void Render(Surface dst, Surface src, Rectangle rect) { for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { dst[x,y] = ColorBgra.Red; } } } I'd like to know if after selecting the entire canvas and running the effect there are any uncolored pixels along the edge. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
Rick Brewster Posted April 9, 2013 Share Posted April 9, 2013 You are right. It is the small sizes that were the problem. It appears to be known issue with the Rectangle struct. var r = new Rectangle(0, 0, 100, 10); Gives r.Right = 100 and r.Bottom = 10 when they should be 99 and 9. Nothing wrong with Paint.NET, cheers. No, this is still working 100% correctly. There is no big vs. small problem. Those values should still be 100 and 10, not 99 and 9! The right-most pixel that's filled in will be "99", but the right edge of that rectangle is a vertical, zero-width line precisely at x=100. Rectangles are defined "bottom/right exclusive" so that when you draw (0,0,100,100) next to (0,100,100,100) there is no seam ... the math works so much better this way. 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...
Bruce Bowyer-Smyth Posted April 9, 2013 Author Share Posted April 9, 2013 It's a weird one. Doing some more testing it only seems to happen during the effect preview. So the codelab script is working fine. Using the basic effect below, put a breakpoint on the line indicated with a condition of "rect.Right == dst.Width" Using an 800x600 the breakpoint is hit during preview and after clicking ok to commit. Opening a 4800x6400 the first rect in the preview is {X=0,Y=0,Width=4798,Height=1} and the breakpoint is never hit during the preview. Click OK and the first rect is {X=4798,Y=0,Width=2,Height=1} and the break point is hit. The preview seems to be missing the width of 2 rects. If you zoom right in on the right hand edge of the image the breakpoint IS hit during the preview. It does seem to be related to zoom levels. If I zoom out 2 times it starts working. This screen size is 1280x1024 and image as opened at zoom level "Window". using PaintDotNet; using PaintDotNet.Effects; using PaintDotNet.PropertySystem; using System.Collections.Generic; using System.Drawing; namespace ClassLibrary1 { [PluginSupportInfo(typeof(PluginSupportInfo), DisplayName = "Width Test")] public class Class1 : PaintDotNet.Effects.PropertyBasedEffect { public static string StaticName { get { return "Width Test"; } } public static Bitmap StaticIcon { get { return new Bitmap(16, 16); } } public Class1() : base(Class1.StaticName, Class1.StaticIcon, SubmenuNames.Blurs, PaintDotNet.Effects.EffectFlags.Configurable | PaintDotNet.Effects.EffectFlags.SingleThreaded) { } protected override void OnRender(Rectangle[] rois, int startIndex, int length) { var dst = base.DstArgs.Surface; foreach (Rectangle rect in rois) { // Breakpoint next line for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { dst[x, y] = ColorBgra.Red; } } } } protected override PropertyCollection OnCreatePropertyCollection() { List<Property> props = new List<Property>(); return new PropertyCollection(props); } } } Quote GPU Blur Plugin | WMF File Plugin 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.