// Target Panel v1.0 by rwp80
// Released 13th July 2008
#region UICode
int Amount1=0;   //[0,255]Blue Lower Capture Threshold
int Amount2=255;   //[0,255]Blue Upper Capture Threshold
int Amount3=0;   //[0,255]Green Lower Capture Threshold
int Amount4=255;   //[0,255]Green Upper Capture Threshold
int Amount5=0;   //[0,255]Red Lower Capture Threshold
int Amount6=255;   //[0,255]Red Upper Capture Threshold
int Amount7=0;   //[0,255]Alpha Lower Capture Threshold
int Amount8=255;   //[0,255]Alpha Upper Capture Threshold
int Amount9=255;   //[0,255]Blue Target Value
int Amount10=0;   //[0,1000]Blue Strength to Target
int Amount11=255;   //[0,255]Green Target Value
int Amount12=0;   //[0,1000]Green Strength to Target
int Amount13=255;   //[0,255]Red Target Value
int Amount14=0;   //[0,1000]Red Strength to Target
int Amount15=255;   //[0,255]Alpha Target Value
int Amount16=0;   //[0,1000]Alpha Strength to Target
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
    ColorBgra CurrentPixel;
    double R, G, B, A;
        
    for(int y = rect.Top; y < rect.Bottom; y++)
    {
        for (int x = rect.Left; x < rect.Right; x++)
        {
            CurrentPixel = src[x,y];
            B = (double)CurrentPixel.B;
            G = (double)CurrentPixel.G;
            R = (double)CurrentPixel.R;
            A = (double)CurrentPixel.A;            
            
            if ((B >= Amount1) && (B <= Amount2) && (G >= Amount3) && (G <= Amount4) && (R >= Amount5) && (R <= Amount6) && (A >= Amount7) && (A <= Amount8))
            {
                B = B+(((double)Amount9-B)*((double)Amount10/1000));                
                G = G+(((double)Amount11-G)*((double)Amount12/1000));                
                R = R+(((double)Amount13-R)*((double)Amount14/1000));                
                A = A+(((double)Amount15-A)*((double)Amount16/1000));                
            }                    
                                                                    
            CurrentPixel = ColorBgra.FromBgra(Utility.ClampToByte(B),Utility.ClampToByte(G),Utility.ClampToByte(R),Utility.ClampToByte(A));
            dst[x,y] = CurrentPixel;
        }
    }
}
