Home › Forums › TWAIN Classic › Capabilitie Trouble when 16 Bit Grayscale Tiff Scanning
- This topic has 4 replies, 5 voices, and was last updated 10 years, 2 months ago by peterlee.
- AuthorPosts
HY!!!
😥
my question:
I have to create an application that scans a document in 16-bit gray scale and saved in TIFF format, uncompressed 600 dpi. Of course I must not use the Epson interface.
With the Epson interface there are no problems but when I try to do the same thing programmatically, I can not set the capabilities in the right way and I always get an error. Using C # visual studio 2010. Is there any good Samaritan who can help me?
The steps are:
1) Select Source (not required)
2) Scan the document in A4 format such as TIFF 16-bit grayscale(without Espon UI)
3) Save to file, or manage it as an array in memory.… Before I committed suicide. Thank you very much and please excuse the language!
Please make sure that you scan in buffered memory mode and not in native mode which can not support 16 bit.
Best regards,
Kaij
http://www.jse.deWhat error message did you get when setting through capabilities? Also, are you using a third-party tool to do the scanning or program from scratch based on the twain specification? If the latter, you can use DG_CONTROL / DAT_IDENTITY / MSG_USERSELEC to get the select source dialog box. ICAP_SUPPORTEDSIZE can be used for page size. For detailed information, you can refer to the specification:
http://twain.org/docs/TWAIN_2_1_Spec.pdf___________________
Adam
Dynamsoft: The leading developer of version control software and TWAIN SDKHi there
I have googled a code for tiff scanning:
RasterEdgeImaging TIFF = new RasterEdgeImaging();
public class AcquisitionClass
{
private bool AcquireCanceled;
private Acquisition Acquisition = new Acquisition(this);
public void Scan()
{
AcquireCanceled = false;
Acquisition.AcquireCanceled += new EventHandler(OnAcquireCanceled);
Acquisition.AcquireFinished += new EventHandler(OnAcquireFinished);
Acquisition.ImageAcquired += new ImageAcquiredEventHandler(OnImageAcquired);
Device activeDevice = Acquisition.ShowSelectSource();
activeDevice.Acquire();
}
private void OnImageAcquired(object sender, AcquireEventArgs e)
{
if (e.Image != null)
{
TiffEncoder enc = new TiffEncoder(TiffCompression.Default, true);
FileStream fs = new FileStream(“1.tif”,FileMode.OpenOrCreate, FileAccess.ReadWrite);
enc.Save(fs, AtalaImage.FromBitmap(e.Image), null);
fs.Close();
}
}
private void OnAcquireCanceled(object sender, EventArgs e)
{
AcquireCanceled = true;
}
private void OnAcquireFinished(object sender, EventArgs e)
{
if (AcquireCanceled)
return;
TiffImageCollection col = new TiffImageCollection();
TiffDecoder dec = new TiffDecoder();
FileStream fs = new FileStream(“1.tif”, FileMode.Open, FileAccess.Read);
int frameCount = dec.GetFrameCount(fs);
fs.Close();
for(int i=0; i< frameCount; i++)
col.Add(new TiffImage(“1.tif”, i, TiffCompressionType.Auto));FileStream outStream = new FileStream(“1.tiff”, FileMode.OpenOrCreate, FileAccess.ReadWrite);
TiffEncoder enc = new TiffEncoder();
enc.Save(outStream, col, null);
}
But it can not word effectively.What’s wrong with my code?
Is there any powerful tiff processing program which supports to do that directly?Thanks a lot.@Nana111 wrote:
Hi there
I have googled a code for tiff scanning:RasterEdgeImaging TIFF = new RasterEdgeImaging();
public class AcquisitionClass
{
private bool AcquireCanceled;
private Acquisition Acquisition = new Acquisition(this);
public void Scan()
{
AcquireCanceled = false;
Acquisition.AcquireCanceled += new EventHandler(OnAcquireCanceled);
Acquisition.AcquireFinished += new EventHandler(OnAcquireFinished);
Acquisition.ImageAcquired += new ImageAcquiredEventHandler(OnImageAcquired);
Device activeDevice = Acquisition.ShowSelectSource();
activeDevice.Acquire();
}
private void OnImageAcquired(object sender, AcquireEventArgs e)
{
if (e.Image != null)
{
TiffEncoder enc = new TiffEncoder(TiffCompression.Default, true);
FileStream fs = new FileStream("1.tif",FileMode.OpenOrCreate, FileAccess.ReadWrite);
enc.Save(fs, AtalaImage.FromBitmap(e.Image), null);
fs.Close();
}
}
private void OnAcquireCanceled(object sender, EventArgs e)
{
AcquireCanceled = true;
}
private void OnAcquireFinished(object sender, EventArgs e)
{
if (AcquireCanceled)
return;
TiffImageCollection col = new TiffImageCollection();
TiffDecoder dec = new TiffDecoder();
FileStream fs = new FileStream("1.tif", FileMode.Open, FileAccess.Read);
int frameCount = dec.GetFrameCount(fs);
fs.Close();
for(int i=0; i< frameCount; i++)
col.Add(new TiffImage("1.tif", i, TiffCompressionType.Auto));
FileStream outStream = new FileStream("1.tiff", FileMode.OpenOrCreate, FileAccess.ReadWrite);
TiffEncoder enc = new TiffEncoder();
enc.Save(outStream, col, null);
}But it can not word effectively.What’s wrong with my code?
Is there any powerful tiff processing program which supports to do that directly?Thanks a lot.Hi, Nana111.
Using code to deal with the related problem is too complicated for me. Why not use some professional tools? You can google it and have a try. I hope you success. Good luck.Best regards,
Peter- AuthorPosts