Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to save scanned image Using Twainlib class to a local path without using Save file dialog box.

Thanks
Tirupati
Posted

Hi,

use the article :

.NET TWAIN image scanner[^]

and in the file GdiPlusLib.cs you can add the following method:

C#
public static bool SaveDIB(IntPtr bminfo, IntPtr pixdat )
{
  string FileName = "C:\\Test.bmp";
  Guid clsid;
  if (!GetCodecClsid(FileName, out clsid))
  {
    MessageBox.Show("Unknown picture format for extension " + Path.GetExtension(FileName), "Image Codec", MessageBoxButtons.OK, MessageBoxIcon.Information );
    return false;
  }
  IntPtr img = IntPtr.Zero;
  int st = GdipCreateBitmapFromGdiDib( bminfo, pixdat, ref img );
  if( (st != 0) || (img == IntPtr.Zero) )
    return false;
  st = GdipSaveImageToFile(img, FileName, ref clsid, IntPtr.Zero);
  GdipDisposeImage( img );
  return st == 0;
}


Calling this method will save the image to the hardcoded file C:\Test.bmp. You can modify this code to fit your needs.
 
Share this answer
 
v2
I'm not sure that I understand your question. Why can't you hard-code the path?
 
Share this answer
 
Post this question in the article's forum (at the bottom of the page):

.NET TWAIN image scanner[^]

Pay more attention to what you're doing. There are plenty of notices that tell you want to do and how to do it on CodeProject.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900