Jump to content

Greyscale question


Recommended Posts

So, I'm trying to create a greyscale heightmap, and basically for whatever reason I have a heightmap that is tainted blue.

Basically what I want to change is make it so that where it's rgb (0, 0, 98) I want it to be rgb (98, 98, 98) and where it's rgb (0, 0, 65) I want it to be rgb (65, 65, 65) and so on. I tried using the simple black & white tool but that doesn't give the result I'm trying to get, as I need to keep the base rgb value of blue the same and basically make the red and green values equal to the blue values throughout the entire image as the red and green values are all 0 currently.

 

Hopefully that makes sense and there's a solution to this.

Thanks!

Link to comment
Share on other sites

This will copy the value of the Blue channel to the Red and Green channels.

void Render(Surface dst, Surface src, Rectangle rect)
{
    ColorBgra CurrentPixel;
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        if (IsCancelRequested) return;
        for (int x = rect.Left; x < rect.Right; x++)
        {
            CurrentPixel = src[x,y];
            CurrentPixel.R = CurrentPixel.G = CurrentPixel.B;
            dst[x,y] = CurrentPixel;
        }
    }
}

https://forums.getpaint.net/topic/111233-codelab-for-average-users-a-laymans-guide/

 

 

Is this what you're looking for?

  • Like 1
  • Upvote 1

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

47 minutes ago, toe_head2001 said:

This will copy the value of the Blue channel to the Red and Green channels.


void Render(Surface dst, Surface src, Rectangle rect)
{
    ColorBgra CurrentPixel;
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        if (IsCancelRequested) return;
        for (int x = rect.Left; x < rect.Right; x++)
        {
            CurrentPixel = src[x,y];
            CurrentPixel.R = CurrentPixel.G = CurrentPixel.B;
            dst[x,y] = CurrentPixel;
        }
    }
}

https://forums.getpaint.net/topic/111233-codelab-for-average-users-a-laymans-guide/

 

 

Is this what you're looking for?

 

Yep! That's exactly what I wanted!

Thanks!

Edited by Matto555
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...