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.
VSTwain1_ImageAcquired And Viewer
Moderator: Alex
Re: VSTwain1_ImageAcquired And Viewer
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
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
Re: VSTwain1_ImageAcquired And Viewer
Hello Jeffrey,
You should use the following code:
It's the best way at the moment. Further we plan to make interaction between our libraries more better.
Best regards, Alexander
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
Best regards, Alexander
Re: VSTwain1_ImageAcquired And Viewer
Thanks Alex! That did the trick.