This project has moved. For the latest updates, please go here.

Setting dpi on the scanner

Jul 2, 2013 at 9:13 PM
When trying to set the dpi to 300 on my scanner it never works, it always leave it set to 96dpi. I check to make sure the scanner can have the dpi set to 300; it can. No matter what I have tried it does not set. the dpi. The scanner is a Fujitsu. Any tips or tricks that will help me get this done?
Jul 3, 2013 at 12:12 PM
Hello, saa3.

To set the dpi, perform the following steps:
  1. Open Data Source Manager (DSM);
  2. Open Data Source (DS)
  3. Set Resolution (dpi);
  4. Acquire image.
The following code shows how to do:
this._twain32.OpenDSM(); // open data source manager
this._twain32.OpenDataSource(); // open data source

#region Get supported resolutions

Twain32.Enumeration _resolutions=this._twain32.GetResolutions();
for(int i=0;i<_resolutions.Count;i++){
    System.Diagnostics.Debug.WriteLine(string.Format("{0:N0} dpi",_resolutions[i]));


this._twain32.SetResolutions(300f); // set XResolution and YResolution (dpi)
this._twain32.Acquire(); // acquire image
For more information see source code of sample Saraff.Twain.Sample2.
Marked as answer by SARAFF on 6/23/2014 at 12:38 PM
Oct 2, 2013 at 8:57 AM

I tried below code but i'm still getting 96 dpi and heigth 3497 and width 2492.
this._twain32.OpenDSM(); // open data source manager
                this._twain32.OpenDataSource(); // open data source
                if((this._twain32.IsCapSupported(TwCap.Duplex)&TwQC.Get)!=0) {
                    var _duplexCapValue=(ushort)this._twain32.GetCap(TwCap.Duplex);
                    if(_duplexCapValue>0) {
                        // 0 - TWDX_NONE
                        // 1 - TWDX_1PASSDUPLEX
                        // 2 - TWDX_2PASSDUPLEX

                        if((this._twain32.IsCapSupported(TwCap.FeederEnabled)&TwQC.Set)!=0) {

                            if((this._twain32.IsCapSupported(TwCap.XferCount)&TwQC.Set)!=null) {

                                if((this._twain32.IsCapSupported(TwCap.DuplexEnabled)&TwQC.Set)!=0) {
                var _supportedSizesCap = this._twain32.IsCapSupported(TwCap.SupportedSizes);
                if ((_supportedSizesCap & TwQC.Set) != 0)
                    this._twain32.SetCap(TwCap.SupportedSizes, (ushort)TwSS.A4);
Oct 2, 2013 at 10:08 AM
Edited Oct 2, 2013 at 4:47 PM
Hello, fatih_senel.
Try this code and tell me what you got.
this._twain32.OpenDSM(); // open data source manager
this._twain32.OpenDataSource(); // open data source
Oct 2, 2013 at 10:43 AM

It's still same(96 Dpi).
Oct 2, 2013 at 4:47 PM
Hello, fatih_senel.
What was the size of the image?
Oct 30, 2013 at 7:35 PM

It's dimensions : 1240x1754 and 96 dpi
Jan 16, 2014 at 4:15 PM
More info:

My tiff image dimensions: 2560 x 3300 which is correct for US letter size paper scanned at 300 dpi, however, when you look at the properties for the image it displays a dpi of 96.
Jan 16, 2014 at 5:13 PM
Hello, saa3.
In the properties for the image displayed dpi for GDI (Graphics Device Interface). Method SetCap sets dpi for scanner, but not for GDI.
Jan 16, 2014 at 5:38 PM
Understood, but, I simply scan the document, than I grab the image using:

Image testImg;
testImg = this._twain32.GetImage(0);

So, I have also tried saving the image directly from the twain object without saving to another image object:

Why is it that the scanner scans at 300 dbi but the image that is stored in the twain object seems to say it is at 96 dbi?

I have stepped through my code checking the objects as I go and the image that is in the _twain32 object reports back 96 dbi, what am I missing?
Jan 16, 2014 at 6:05 PM
Hello, saa3.
var _img = this._twain32.GetImage(0) as Bitmap; 
Jan 16, 2014 at 6:32 PM
Excellent. That does it. Sorry for being thick as a brick.
I am very happy with the driver and only had the one sticking point.
Jan 17, 2014 at 5:34 AM
Edited Jan 17, 2014 at 5:39 AM
Hello, i have some problem like saa3, but this method don't help me. Resolution remains on 96x96, i can see it.
I have a button and when i click on it, it must scan image and recog. I tried over and over again: twain.OpenDataSource() and SetResolutions(300f) put in MainWindow section, but it doesn't work. And so I wrote this:
private void scan_button_Click(object sender, RoutedEventArgs e)
            twain.ShowUI = false;
There's this code In MainWindows section:
 public MainWindow()
            twain.AcquireCompleted += new EventHandler(_AcquireCompleted);
In _AcquireCompleted:
System.Drawing.Image img =  twain.GetImage(0);
            textBox.Text(img.HorizontalResolution.ToString()+ "x" + img.VerticalResolution.ToString());
And textbox write "96x96".
Help me. Thx.
Jan 17, 2014 at 6:08 AM
Hello, DyGer.

Try follow code:
 public MainWindow(){
            this.twain.ShowUI = false;
            twain.AcquireCompleted += new EventHandler(_AcquireCompleted);

private void scan_button_Click(object sender, RoutedEventArgs e){