tev Posted June 26, 2022 Share Posted June 26, 2022 I'm working on a plugin that isolates and rearranges certain areas of a file while essentially deleting the un-wanted areas: very minimal plugin as it's my first. Running into an issue where assigning the currentPixel variable to be transparent is not bearing any change. void Render(Surface dst, Surface src, Rectangle rect) { // Delete any of these lines you don't need Rectangle selection = EnvironmentParameters.SelectionBounds; int centerX = ((selection.Right - selection.Left) / 2) + selection.Left; int centerY = ((selection.Bottom - selection.Top) / 2) + selection.Top; ColorBgra currentPixel; for (int y = 0; y <= 558; y++) // Scoping through. { if (IsCancelRequested) return; for (int x = 0; x <= 584; x++) { currentPixel = src[x,y]; if (x == 231 && y == 74) { // Basic test to change a select pixel, works fine. currentPixel = ColorBgra.Red; } else { currentPixel = ColorBgra.Transparent; // This here is the issue. // The destination and source pixel are the still same after the assignment. } dst[x,y] = currentPixel; } } } I thought maybe initializing the dst array to be empty(?), not even sure how to work that. Quote Link to comment Share on other sites More sharing options...
BoltBait Posted June 26, 2022 Share Posted June 26, 2022 Try this: void Render(Surface dst, Surface src, Rectangle rect) { for (int y = rect.Top; y < rect.Bottom; y++) // Don't change this { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) // or this { ColorBgra CurrentPixel = src[x,y]; if (x == 231 && y == 74) { CurrentPixel = ColorBgra.Red; } else { CurrentPixel = ColorBgra.Transparent; } dst[x,y] = CurrentPixel; } } } You may want to read these tutorials: https://boltbait.com/pdn/codelab/help/overview.php Good luck! Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
tev Posted June 26, 2022 Author Share Posted June 26, 2022 I completely goofed; I was working on a new empty layer the entire time instead of my target background layer. Thank you for the response, anyways, much appreciated! Quote 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.