Class Diagram


The PixelRule contains a definition of PixelRanges for one specific color. Also included are the definitions, how the color will be manipulated and replaced.

A PixelRule is just a container of informations for the PixelReplacer. A rule can be generated by Code (see example) or with a RuleParser.

The "Match" function does check, if a color will be recognized by this rule and just checks the "IsBetween" function of every color channel (ARGB).


//Create a new pixelrule
PixelRule myrule = new PixelRule();

//Set the name
myrule.Name = "Red Lime filter";

//Set the filters for recognition
 for channels, we don't want to filter
 we give them a range from 0, 256
 because we want to recognize them always
myrule.A = new PixelRange(0, 256);
//We want to catch the red channel
myrule.R = new PixelRange(0, 50);
myrule.G = new PixelRange(0, 256);
myrule.B = new PixelRange(0, 256);

/*Now we set the properties which
  are relevant for the replacing*/

//The old color will be replaced through this
myrule.NewColor = Color.Orange;

//If you want to adapt (mix) the colors
myrule.AdaptColors = true;

//Check if it would match:
bool doesMatch = myrule.Match(Color.Lime);

Last edited Feb 1, 2011 at 3:23 PM by cansik, version 7


No comments yet.