<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>StepSix &#187; WIA</title>
	<atom:link href="http://stepsix.org/tag/wia/feed/" rel="self" type="application/rss+xml" />
	<link>http://stepsix.org</link>
	<description></description>
	<lastBuildDate>Fri, 11 Jun 2010 07:32:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>An intro to WIA (Windows Image Acquisition) in C# (Part 1)</title>
		<link>http://stepsix.org/2010/03/31/an-intro-to-wia-windows-image-acquisition-in-c-part-1/</link>
		<comments>http://stepsix.org/2010/03/31/an-intro-to-wia-windows-image-acquisition-in-c-part-1/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 04:29:22 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Programing]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[C♯]]></category>
		<category><![CDATA[WIA]]></category>

		<guid isPermaLink="false">http://stepsix.org/?p=56</guid>
		<description><![CDATA[Windows Image Acquisition is a platform for accessing images from cameras, scanners, and webcams. Recently I’ve been working on a project that involves a scanner. As it turns out for basic use WIA is very easy to use, however once &#8230; <a href="http://stepsix.org/2010/03/31/an-intro-to-wia-windows-image-acquisition-in-c-part-1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Windows Image Acquisition is a platform for accessing images from cameras, scanners, and webcams. Recently I’ve been working on a project that involves a scanner. As it turns out for basic use WIA is very easy to use, however once you attempt to do more advanced things the friendly resources begin to dwindle leaving you with the cold emotionlessness of MSDN. However, this being my first major project I refused to give up and finally found out how to do almost everything I wanted to do. In this post, the first of this series, I’ll talk about acquiring an image from a flatbed scanner.</p>
<p><span id="more-56"></span></p>
<p>First let’s start by looking at the easiest way to acquire an image from a scanner. Begin by adding a reference to the Microsoft Windows Image Acquisition Library v2.0, this can be found under COM.</p>
<p>Don’t forget to put the proper using statement at the top of your code.</p>
<pre class="brush:csharp">using WIA;</pre>
<p>Before we create our scanning function we need to create two objects, one for access to WIA’s common dialogs and another to hold our image after it is scanned.</p>
<pre class="brush:csharp">CommonDialog dialog = new WIA.CommonDialog();
ImageFile scannedImage = null;</pre>
<p>Now let’s create a function to scan our document and save it.</p>
<pre class="brush:csharp">void Scan()
{
    scannedImage = dialog.ShowAcquireImage(
                        WiaDeviceType.ScannerDeviceType,
                        WiaImageIntent.UnspecifiedIntent,
                        WiaImageBias.MaximizeQuality,
                        FormatID.wiaFormatPNG,
                        true, true, false);
    scannedImage.SaveFile("scannedImage.png");
}</pre>
<p>As if by magic when Scan() is called a wizard appears and walks you through scanning a document. If you are acquiring only one image and don’t want any further customization to the interface then you can stop here and you won’t be missing anything.</p>
<p>However I found this wizard to be too slow. I wanted my users to be able to click one button and have the scanner jump into action.</p>
<p>To start we need to add two more WIA objects to our code. A DeviceManger object and a device object.</p>
<pre class="brush:csharp">DeviceManager deviceManager = new DeviceManagerClass();
Device scanner = null;</pre>
<p>WIA has another really nice dialog in its CommonDiolog class that allows the user to select a Device and the dialog will actually return the device for you.</p>
<pre class="brush:csharp">scanner = dialog.ShowSelectDevice(
          WiaDeviceType.ScannerDeviceType, false, false);</pre>
<p>Now that you have the device selected lets modify our Scan() method to scan with our newly selected device.</p>
<pre class="brush:csharp">Void Scan()
{
    Item item = device.Items[1];
    scannedImage = dialog.ShowTransfer(item,
                   FormatID.wiaFormatPNG, false) as ImageFile;
    scannedImage.SaveFile(“scannedImage.png”)
}</pre>
<p>Now we are back where we were before but this time running the Scan() method will tell the scanner to immediately start scanning and our user won’t have to sit though a multipage wizard.</p>
<p>I think this is a good point to stop for now. In a little while Ill post the second part to this post covering how to change properties such as DIP and switching between grayscale and color.</p>
]]></content:encoded>
			<wfw:commentRss>http://stepsix.org/2010/03/31/an-intro-to-wia-windows-image-acquisition-in-c-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

