TV effect

Pattern design

Such a kind of effect is easy to produce, the idea is to overlay a pattern, made up of white lines and lines with another colors, over the original image.

The white lines and the lines with the other color (other than white) are mixed with the corresponding pixels of the original image by the use of the alphablending technique.

The image below illustrates the three parameters used for pattern definition:

The pattern is not a bitmap and then does not use any resources, it is dynamically manageed by the use of variables as described by the part of code below:

//lCount is the current line index in the pattern,
//it is set to the "First line" parameter (vertical offset)
//loop of rows of pixels
for (j=0;j<h;j++)  
   //the "Dark" flag is set to "1" if the pointed line, by
   //the lCount variable, is not a white line, and otherwise 
   //set to "0".
   //lCount is also incremented (next line in pattern).
   if(lCount++<pTV->NBBrigthlines) Dark=1; else Dark=0;
   //loop of pixels in a row
   for (i=0; i<w; i++)
     if (Dark)
     {  //alphablending with the other color 
     { //alphablending with the white color
   //next line in the pattern
   if(lCount>=pTV->NBlines) lCount=0;


Examples of two different patterns, defined by different values of parameters:

Note that the "Bright lines" parameter is equal to the number of lines with another color than white one and it is also the position of the first white line in the pattern, so this name is a little bit ambiguous but you can change it.