Implementation of 2D to 1D Array Formula in Image Processing

public void Invert(ref Bitmap bmp)
{

BitmapData newData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height),
ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

int total_size = newData.Stride * newData.Height;
byte[] g_PixBytes = new byte[total_size + 1];
byte[] g_OutBytes = new byte[total_size + 1];

Marshal.Copy(newData.Scan0, g_PixBytes, 0, total_size);

 

for (int y = 0; y < bmp.Height; y++)
{

for (int x = 0; x < bmp.Width; x++)
{

int pix = y * newData.Stride + 3 * x;               //2D to 1D Array Formula

g_OutBytes[pix + 2] = (byte)(255 – g_PixBytes[pix + 2]);
g_OutBytes[pix + 1] = (byte)(255 – g_PixBytes[pix + 1]);
g_OutBytes[pix + 0] = (byte)(255 – g_PixBytes[pix + 0]);
}
}

Marshal.Copy(g_OutBytes, 0, newData.Scan0, total_size);

bmp.UnlockBits(newData);

g_PixBytes = null;
g_OutBytes = null;

}

//Simple image invert filter by C# programming language.

2D to 1D Array

 

-2D(Width, Height) to 1D Array Formula = Y * Width + X

-Example of a 2D array with size:
Width = 20, Height = 50
-Example position(X, Y) in this array:
X = 15
Y = 35

-Representing this 2D position by a 1D Array:
–> Y * Width + X
–> 35 * 20 + 15
–> 715

Sumatra PDF: Free PDF Reader

Sumatra PDF is a free and open-source document viewer that supports many document formats including: Portable Document Format (PDF), Microsoft Compiled HTML Help (CHM), DjVu, EPUB, FictionBook (FB2), MOBI, PRC, Open XML Paper Specification (OpenXPS, OXPS, XPS), and Comic Book Archive file (CB7, CBR, CBT, CBZ).[3] If Ghostscript is installed, it supports PostScript files. It is developed exclusively for Microsoft Windows.

Download

Internet Mapping Project

Fig. Internet Map

 

The Internet Mapping Project was started by William Cheswick and Hal Burch at Bell Labs in 1997. It has collected and preserved traceroute-style paths to some hundreds of thousands of networks almost daily since 1998. The project included visualization of the Internet data, and the Internet maps were widely disseminated.

Dvdisaster

Dvdisaster provides additional ECC protection for optical media. If a medium gets damaged, dvdisaster can recover it as long as the amount of damage is smaller than the amount of ECC data you added to protect it.

Download