SetJPEGCompression Example for C++ 5.0 and later

ILEADRasterTwain_U * pRasterTwain;

HRESULT hr = ::CoCreateInstance(CLSID_LEADRasterTwain_U, NULL, CLSCTX_ALL, IID_ILEADRasterTwain_U, (void **)&pRasterTwain);
if (FAILED(hr) || !pRasterTwain)
{
	::MessageBox (NULL, _TEXT("Failed to create a Raster Twain Object"), _TEXT("Error"), MB_OK);
	return;
}

pRasterTwain->InitSession((long)GetSafeHwnd()); 
pRasterTwain->SelectSource();

short nRet = pRasterTwain->GetJPEGCompression(L_LTWAIN_GET_JPEG_COMPRESSION); 
if (nRet == 0) 
{
	pRasterTwain->GetJPEGCompressionData ()->ColorSpace = L_TWPT_GRAY; 
	pRasterTwain->GetJPEGCompressionData()->SubSampling = 0x10001000; 
	pRasterTwain->GetJPEGCompressionData()->NumComponents = 1; 
	pRasterTwain->GetJPEGCompressionData()->RestartFrequency = 0; 
	pRasterTwain->GetJPEGCompressionData()->PutQuantMap(0, 0); 
	pRasterTwain->GetJPEGCompressionData()->PutHuffmanMap(0, 0); 

	nRet = pRasterTwain->SetJPEGCompression(L_LTWAIN_SET_JPEG_COMPRESSION); 
	if (nRet == 0) 
		::MessageBox(NULL, TEXT("Set JPEG compression options is success"), ("Notice!"), MB_OK); 
}