Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Monday, March 13, 2006 6:19:14 PM(UTC)

STech  
STech

Groups: Registered
Posts: 6


Hi

Does anyone know how to set the Quality Factor of the JPEG file when scanning using AcquireMulti() method?

See the code below:

Private Sub RasterTwain_AcquireMultiEvent(ByVal nPage As Integer, ByVal bstrFileName As String, ByVal bFinishScan As Boolean)
   Dim strMsg As String

   If bFinishScan Then
      strMsg = "The page # " + CStr(nPage) + " is scanned and saved to file name " + bstrFileName
      MsgBox strMsg
   End If
End Sub

Private Sub Command1_Click()
   Dim nRet As Integer

   RasterTwain.FastTransferMode = L_LTWAIN_BUFFER_MODE
   RasterTwain.FastFormat = FILE_JPEG
   RasterTwain.FastBitsPerPixel = 24
   RasterTwain.FastBufferSize = 0
   RasterTwain.FastUsePreferredBufferSize = True
   RasterTwain.EnableAcquireMultiEvent = True
   RasterTwain.XResolution = 150

   RasterTwain.YResolution = 150

   ' How to change the Quality factor ???

   nRet = RasterTwain.AcquireMulti("C:\IMAGES\MULIMG.JPG", 0, True)
   If nRet = 0 Then
      MsgBox "The Fast Twain method was successful", vbOKOnly, "Notice"
   Else
      MsgBox "Error occurred during the fast Twain method!!!", vbOKOnly, "Error!!!"
   End If
End Sub

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Tuesday, March 14, 2006 5:35:23 AM(UTC)
ewintermyer

Groups: Registered
Posts: 8


The only way I know how to do this is by loading the image into the Lead main control or raster view control in the AcquireMultiEvent then saving it with the desired quality.

This example uses the Lead Main Control, but you can do something similar with the Lead Raster View control and LeadRasteIO

You have to look at the boolean bFinishScan becuase this event is fired twice for each page scanned.

Note from Leads help file: you can also use a factor of 0 to produce lossless JPEG files

Private Sub RasterTwain_AcquireMultiEvent(ByVal nPage As Integer, ByVal bstrFileName As String, ByVal bFinishScan As Boolean)
    If bstrFileName <> vbNullString And bFinishScan Then
        intRet = mvarLdImage.Load(bstrFileName, 24, 0, 1)
        mvarLdImage.Save bstrFileName, FILE_JPEG, 24, 0, SAVE_OVERWRITE
    End If

End Sub

 
#3 Posted : Wednesday, March 15, 2006 6:59:55 AM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 353


Thank you ewintermyer for your contribution. Your suggestion should
works with any type of Twain driver, but it doesn't make use of the scanner's compression abilities if it has them.

For a Twain source with inbuilt JPEG scanning, you could use the
ICAP_JPEGQUALITY capability (if it's supported) to control the quality
level. The Twain Specification states the allowed values for this capability.


Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2019, Yet Another Forum.NET
This page was generated in 0.155 seconds.