MadJik Posted December 28, 2006 Share Posted December 28, 2006 I'm working on some code lab effect and I have some strange result with the preview. This is the image I'm working with for the tests. This is the code I'm using: void Render(Surface dst, Surface src, Rectangle rect) { double step = 50 / 100.0f; double stepx = 0 / 100.0f; PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { double yreflect = (double)(y + x * step); if (yreflect < 0) yreflect += dst.Height; if (yreflect >= dst.Height) yreflect -= dst.Height; double xreflect = (double)(x + y * stepx); if (xreflect < 0) xreflect += dst.Width; if (xreflect >= dst.Width) xreflect -= dst.Width; if (selectionRegion.IsVisible((int)xreflect, (int)yreflect)) { dst[(int)xreflect, (int)yreflect] = src[x, y]; } } } } Playing with the values for step and stepx I want to obtain an oblic view of the image. I obtain this strange preview (printscreen) And when I press Ok the final image is good! Am I doing something wrong in the code or is this a bug? Quote My DeviantArt | My Pictorium | My Plugins | Donate via Paypal Link to comment Share on other sites More sharing options...
Illnab1024 Posted December 28, 2006 Share Posted December 28, 2006 dst[(int)xreflect, (int)yreflect] = src[x, y]; Due to the PdN Render method, you need to use the same destination pixel that's in the for loop for it to work properly... e.g. dst[x, y] = src[...] Quote ~~ Link to comment Share on other sites More sharing options...
Rick Brewster Posted December 28, 2006 Share Posted December 28, 2006 Illnab is right. You can't just render whatever destination pixels you feel like. You must render only and all the pixels that the rectangle passed to you describes. 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...
MadJik Posted December 29, 2006 Author Share Posted December 29, 2006 Ok, nice to know... I have to change my point of view and my code too! Thanks for answers. Quote My DeviantArt | My Pictorium | My Plugins | Donate via Paypal 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.