Jump to content

Code lab preview is corrupted


Recommended Posts

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?

Link to comment
Share on other sites

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.

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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