Leadtools TWAIN (Leadtools.Twain assembly)
LEAD Technologies, Inc

SetJpegCompression Method

Example 





JPEG Compression data to be set
Indicates the JPEG compression values to set
Sets the JPEG compression options for the current TWAIN session. This method lets the user set JPEG compression options for the current TWAIN session or reset the default JPEG compression options for the current TWAIN session, depending on the flag passed to the flag parameter.
Syntax
public void SetJpegCompression( 
   TwainJpegCompression compression,
   bool resetValues
)
'Declaration
 
Public Sub SetJpegCompression( _
   ByVal compression As TwainJpegCompression, _
   ByVal resetValues As Boolean _
) 
'Usage
 
Dim instance As TwainSession
Dim compression As TwainJpegCompression
Dim resetValues As Boolean
 
instance.SetJpegCompression(compression, resetValues)
public void SetJpegCompression( 
   TwainJpegCompression compression,
   bool resetValues
)
 function Leadtools.Twain.TwainSession.SetJpegCompression( 
   compression ,
   resetValues 
)
public:
void SetJpegCompression( 
   TwainJpegCompression compression,
   bool resetValues
) 

Parameters

compression
JPEG Compression data to be set
resetValues
Indicates the JPEG compression values to set
Remarks
Depending upon the flag used, this method will either set JPEG compression options for the current TWAIN session, or restore the default JPEG compression options for the current TWAIN session.
For more information, refer to Using JPEG Compression For A TWAIN Source.
Example
 
Public Sub SetJpegCompressionExample(ByVal parent As IWin32Window)
   Dim session As TwainSession = New TwainSession()
   session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None)

   Try
      Dim myJpeg As TwainJpegCompression = session.GetJpegCompression(False)
      Dim data As TwainMemoryData() = New TwainMemoryData(0) {}

      myJpeg.ColorScheme = TwainColorScheme.Gray
      myJpeg.SubSampling = &H10001000
      myJpeg.ColorComponentCount = 1
      myJpeg.RestartFrequency = 0

      Dim quantMap As Integer() = New Integer(0) {}
      quantMap(0) = 0
      myJpeg.SetQuantizationMap(quantMap)

      Dim haffmanMap As Integer() = New Integer(0) {}
      haffmanMap(0) = 0
      myJpeg.SetHuffmanMap(haffmanMap)
      myJpeg.SetQuantizationTable(data)
      myJpeg.SetHuffmanDC(data)
      myJpeg.SetHuffmanAC(data)

      session.SetJpegCompression(myJpeg, False)
      MessageBox.Show("Set JPEG compression options is success")
   Catch ex As Exception
      MessageBox.Show(ex.Message)
   End Try

   session.Shutdown()
End Sub
public void SetJpegCompressionExample(IWin32Window parent)
{
   TwainSession session = new TwainSession();
   session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None);

   try
   {
      TwainJpegCompression myJpeg = session.GetJpegCompression(false);
      TwainMemoryData[] data = new TwainMemoryData[1];

      myJpeg.ColorScheme = TwainColorScheme.Gray;
      myJpeg.SubSampling = 0x10001000;
      myJpeg.ColorComponentCount = 1;
      myJpeg.RestartFrequency = 0;

      int[] quantMap = new int[1];
      quantMap[0] = 0;
      myJpeg.SetQuantizationMap(quantMap);

      int[] haffmanMap = new int[1];
      haffmanMap[0] = 0;
      myJpeg.SetHuffmanMap(haffmanMap);
      myJpeg.SetQuantizationTable(data);
      myJpeg.SetHuffmanDC(data);
      myJpeg.SetHuffmanAC(data);

      session.SetJpegCompression(myJpeg, false);
      MessageBox.Show("Set JPEG compression options is success");
   }
   catch (Exception ex)
   {
      MessageBox.Show(ex.Message);
   }

   session.Shutdown();
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

TwainSession Class
TwainSession Members
GetJpegCompression Method

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.