Jump to content

Turning source pixels to transparent pixels in destination.


tev

Recommended Posts

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.

Link to comment
Share on other sites

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!

 

Link to comment
Share on other sites

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!

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.

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