VSTwain1_ImageAcquired And Viewer

Questions, comments and suggestions concerning VintaSoft Twain .NET SDK.

Moderator: Alex

Post Reply
jeffrey
Posts: 3
Joined: Thu Sep 04, 2008 7:25 am

VSTwain1_ImageAcquired And Viewer

Post by jeffrey » Thu Sep 04, 2008 7:41 am

What is the best way to add an acquired image to a Vintasoft.Imaging.ImageViewer?
I have placed the following code in the VSTwain1_ImageAcquired event and seems to work with an exception to gray scale images.

Private Sub VSTwain1_ImageAcquired(ByVal sender As Object, ByVal e As System.EventArgs) Handles VSTwain1.ImageAcquired
ImageViewer1.Images.Add(VSTwain1.GetImage(VSTwain1.NumImages - 1))
End Sub

The images show up fine in the ImageViewer. If I rotate the image using "Me.ImageViewer1.FocusedImage.Rotate(90)" the image rotates as expected. My problem is this. If the images scanned from the scanner are gray scale(8-bit) images, then after a rotate, the image becomes distorted with a red-ish overlay. Also if I scan and do nothing but save the image and then open it again, the image contains the distorted red-ish overlay. Here is the code I use to save to file. imageViewer1.Images.Save(Me.FilePath).

Note: I can duplicate the issue using the same code on two different hp scanner models.

jeffrey
Posts: 3
Joined: Thu Sep 04, 2008 7:25 am

Re: VSTwain1_ImageAcquired And Viewer

Post by jeffrey » Thu Sep 04, 2008 8:11 am

Additional info. I added the following code to work around my issue. In the VSTwain1.ImageAcquired event I used VSTwain1.SaveImage(VSTwain1.NumImages - 1, fpath) where fpath is a temp path to store the file on disk. I then add the image from disk to the Imageviewer like this. Me.ImageViewer1.Images.Add(fpath). This solves the distorted image problem.

Dim TempFileName As String = Guid.NewGuid.ToString & ".tif"
Dim fpath As String = IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.Temp, TempFileName)
VSTwain1.SaveImage(VSTwain1.NumImages - 1, fpath)
Me.ImageViewer1.Images.Add(fpath)

Is there a better way to make this work?

Thanks,
Jeffrey

Alex
Site Admin
Posts: 1474
Joined: Thu Jul 10, 2008 2:21 pm

Re: VSTwain1_ImageAcquired And Viewer

Post by Alex » Thu Sep 04, 2008 5:28 pm

Hello Jeffrey,

You should use the following code:

Code: Select all

Private Sub VSTwain1_ImageAcquired(ByVal sender As Object, _
                                   ByVal e As System.EventArgs) Handles VSTwain1.ImageAcquired
    ImageViewer1.Images.Add(New Bitmap(VSTwain1.GetImage(VSTwain1.NumImages - 1)))
End Sub
It's the best way at the moment. Further we plan to make interaction between our libraries more better.

Best regards, Alexander

jeffrey
Posts: 3
Joined: Thu Sep 04, 2008 7:25 am

Re: VSTwain1_ImageAcquired And Viewer

Post by jeffrey » Thu Sep 04, 2008 5:40 pm

Thanks Alex! That did the trick.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest