BoltBait's Pages - Scanlines

Sarcasm, just one of the services I offer.

Paint.NET Scanlines Effect

This is just a quick hack to add scanlines to a layer.  Scan lines are black lines inserted every few lines of your drawing to make your drawing look like it is showing on television.  Once you run this effect it might look good to glow the resulting layer a little bit.  Or, not.  Your choice.


The Idea

I just opened the source code to my Grid Maker plugin and took out all the stuff that didn't fit!


The Effect DLL

You can download the precompiled effect DLL here: ScanLines.dll

Just drop this file in your \program files\Paint.NET\effects directory and you should be all set.

If you need help installing effects, read this page: Installing Effects 


Instructions for Use

The best way to use this is to follow these steps:

1.  Open your graphic.

2.  Click the Effects menu and select Render > Scan Lines

3.  Adjust the sliders for the desired effect.


Source Code

Here is the CodeLab script that you can compile yourself:

int Amount1=5; //[2,25]Scanline Width
int Amount2=1; //[1,5]Brush Width
int Amount3=0; //[0,1]Horizontal Vertical

void Render(Surface dst, Surface src, Rectangle rect) 
 // User Interface elements 
 int GridSize = Amount1; 
 bool SwapColors = (Amount2 == 1); 

 // Other variables 
 PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); 
 ColorBgra CurrentPixel; 
 bool Odd = false; 

 // Get the current brush width for grids 
 int w = Amount2; 
 bool Orientation = (Amount3 == 0);

 ColorBgra PrimaryColor;
 PrimaryColor.A = 255;
 PrimaryColor.R = 0;
 PrimaryColor.G = 0;
 PrimaryColor.B = 0;
 // Loop through all the pixels 
 for(int y = rect.Top; y < rect.Bottom; y++) 
 for (int x = rect.Left; x < rect.Right; x++) 
 // Only work with a pixel if it is selected 
 // (this handles convex & concave selections) 
 if (selectionRegion.IsVisible(x, y)) 
 // Get the source pixel 
 CurrentPixel = src[x,y]; 
 Odd = false; 
 for (int t=0; t<w; t++) 
 if (Orientation)
	 if (((y-t) % GridSize) == 0) 
 	 Odd = true; 
	 if (((x-t) % GridSize) == 0) 
 	 Odd = true; 
 if ( Odd ) 
 CurrentPixel.R = (byte)PrimaryColor.R; 
 CurrentPixel.G = (byte)PrimaryColor.G; 
 CurrentPixel.B = (byte)PrimaryColor.B; 
 CurrentPixel.A = (byte)PrimaryColor.A; 
 // Save the (modified?) pixel 
 dst[x,y] = CurrentPixel; 

Wednesday, April 11, 2007