How to easily record from a webcam in C#

What is the easiest way to use a webcam in C# and record from it? If you search for an answer to this question you’ll find a lot of articles in the internet but most of them are many pages long and very confusing. However that isn’t really necessary. With the aid of the AForge.NET library you can do the given task really easy. Just a few lines of C# code are enough to drive your webcam and capture images from it. In the following I’ll show you how to handle the AForge library.
What do you need?

The AForge.Video.dll together with the AForge.Video.DirectShow.dll
Both dlls can be found on the AForge website inside the “(libs only)” zip-archive.
A simple winforms-application, with a picturebox on its gui
A webcam. For example this one:[aawp bestseller=”1080p webcam” items=”1″ template=”list”]
Basic C#-knowledge. If not exists, read this: [aawp box=”0985580135″ template=”list”]

At first you have to reference the both dlls and write […]

Compress images with jpeg codec in C#

Today I’ll show you how to compress your images with help of the JPEG-codec in C#. You will be able to choose the grade of compression. So it’s your choice, if the function should produce smaller filesize or better quality of images.

private void CompressImage(Image sourceImage, int imageQuality, string savePath)
{
try
{
//Create an ImageCodecInfo-object for the codec information
ImageCodecInfo jpegCodec = null;

//Set quality factor for compression
EncoderParameter imageQualitysParameter = new EncoderParameter(
System.Drawing.Imaging.Encoder.Quality, imageQuality);

//List all avaible codecs (system wide)
ImageCodecInfo[] alleCodecs = […]

Capture a complete website in C#

To take a screenshot is one thing. One click on the print key or a small program, which uses the c# screenshot capture method, I showed you the last time, are enough to take a beautiful screenshot.
But what should you do, if you want to capture a whole website? The most websites are “longer” as your screen is high. Thereby most common ways to capture a screenshot will become useless.
But don’t fear – C# can of course solve this problem. If you want to capture a screenshot of a complete website, take a look at the following snippet.

private void WebsiteScreenshot(string url, string file)
{
//Create a webbrwoser object
WebBrowser browser = new WebBrowser();

//Deactivate scrollbars, unless you want them to
//appear on your screenshot
browser.ScrollBarsEnabled = false;

[…]

How to take a screenshot in C#

The subsequent code snippet can be used to take screenshots in C#.Net. The screenshots, you capture with the following snippet, equal to the screenshots you take by pressing the print-key on your keyboard. (Certainly aside from the fact that the screenshot won’t be in your clipboard, but you will get a bitmap object, which can be used to manipulte in anyway you like in C#.)
Because the the source code is very short, I’ll let it speak for itself.

private Bitmap Screenshot()
{
//Create a bitmap with the same dimensions like the screen
Bitmap screen = new Bitmap(SystemInformation.VirtualScreen.Width,
SystemInformation.VirtualScreen.Height);

//Create graphics object from bitmap
[…]

How to normalize mp3-files in C#

Who doesn’t know the following situation? You create a playlist with your favorite songs, looking forward to a leisurely afternoon on the couch and nevertheless the right mood won’t be there.
The first song roars at you, so you take your remote and turn down your music. The next song is so quiet, that it’s really hard to understand anything. So you turn you volume up again. And so on…
The magic word for this problem is normalization. Goal of normalization is that every song has the same maximum volume level. So you can still hear the difference between quiet and loud parts of a song, but the volume level of the songs to each other is adjusted.
Today I’ll show you how to write a program in C# which can normalize your music files.
What do you need?

The mp3gain.exe, which can be downloaded from my blog
The following snippet of C#-code

private void mp3Normalization()
{
[…]

cheap jerseys china jerseys wholesale