I have a picture with blue and green colors with each color being composed of different tones. I want the program to turn all of the blue tones into the solid color yellow while leaving the green tones alone. The reason that a solid color is desired is so that it can be made transparent. The user moves a paintbox over the blue color for example, then the program puts all the colors under the paintbox into an array.
The program gets the color for every pixel (var1) in the picture and then decides whether or not to change it to yellow of some other color. I've been trying two methods.
The first method shown below is similar to what you suggested. It checks to see if each pixel is in the array. If it is then it is changed to yellow. Otherwise it's left alone. It's accurate because it leaves the green pixels alone but it's very slow because it must go through the entire array for every pixel even if the array is sorted to remove redundant numbers and I also found out that I had to take many samples with each sample being a repeat of the whole process. The problem is compounded by the fact that the program also works with videos and in such cases will have to alter all of the frames of each video.
The second method is very much faster and it works for some pictures but not the picture that I'm talking about. This method gets the lowest and highest numbers in the array (lowvar and highvar respectively) and if the pixel number var1 is between them it gets changed to yellow. The variable lowvar = 592895 and highvar = 1575423. Unfortunately the number for the green color (var1) is 917259 so it gets erroneously changed to yellow because that number is between lowvar and highvar. This can only mean that the color numbers for blue aren't necessarily in sequence as I hoped they would be!
The green color 917259 is definitely not in the array and that's why method 1 works.
In the color chart for predefined color constants the decimal number for clBlue is 16711680 but I don't know the numbers for all of its tones or where they begin and end. The same goes for lime green.
tempstr := ColorToHex(image5.canvas.Pixels[pointx,pointy]);
var1 := Hex2Dec(tempstr);
for newcount := 1 to colorcounter do
begin
tempstr := coloritem[newcount];
var2 := Hex2Dec(tempstr);
if var1 = var2 then
image5.canvas.Pixels[pointx,pointy] := colordialog1.Color;
end;
//2nd method - lowvar is the lowest number in the array and highvar is the highest number in the array
tempstr := ColorToHex(image5.canvas.Pixels[pointx,pointy]);
var1 := Hex2Dec(tempstr);
if (var1 >= lowvar) and (var1 <= highvar) then
image5.canvas.Pixels[pointx,pointy] := colordialog1.Color;
]
Thanks again for your help. I would be glad to hear any ideas about how to proceed.