0

Red has been turned to white, now how do I turn blue to black?

I have written a new loop next to the first loop but it does not work.

if image is all blue
    red = 0x00
    blue = 0x00
    green = 0x00

Update: I have written this code and all I get is an error message.

        if(triple.rgbtBlue < 0xff0000 || triple.rgbtBlue > 0x000000)
        {
            triple.rgbtRed = 0x00;
            triple.rgbtBlue = 0x00;
            triple.rgbtGreen = 0x00;
        }

Update 2: I have changed the code and now almost everything turns black. What am I doing wrong?

        if(triple.rgbtRed == 0xff)
        {
            triple.rgbtRed = 0xff;
            triple.rgbtBlue = 0xff;
            triple.rgbtGreen = 0xff;
        }
        if(triple.rgbtBlue == 0xff)
        {
            triple.rgbtRed = 0x00;
            triple.rgbtBlue = 0x00;
            triple.rgbtGreen = 0x00;
        }
1

I'm guessing your error is about comparing a constant to triple.rgbtBlue. Keep in mind that triple.rgbtBlue is just a byte; its values don't range from 0x000000 to 0xff0000, but rather from 0x00 to 0xff. So, you'll want to compare against a different number.

1

Remember that white is represented by ffffff or when red, green, and blue are all 0xff. So when you search for triple.rgbtBlue == 0xff, you will also find all the pixels colored white. That's why almost your entire image is turned black

0

It's pretty straightforward, but you have to decide what is blue. Are you only interested in pixels that are fully blue - FF for the blue part and 00 for Red and Green -- or maybe greater than a certain level of blue and/or below a certain level of red and green? Once you decide that, create the code to search for these requirements, and when found, change to all zeros as you've outlined.

1
  • I have updated my question.
    – risingland
    Mar 3 '16 at 4:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .