/* Sets the number of images which can be accpeted by the application at one time */ BOOL CTwain::SetImageCount(TW_INT16 nCount) { if(SetCapability(CAP_XFERCOUNT,(TW_UINT16)nCount,TRUE)) { m_nImageCount = nCount; return TRUE; } else { if(GetRC() == TWRC_CHECKSTATUS) { TW_UINT32 count; if(GetCapability(CAP_XFERCOUNT,count)) { nCount = (TW_INT16)count; if(SetCapability(CAP_XFERCOUNT,nCount)) { m_nImageCount = nCount; return TRUE; } } } } return FALSE; }
/** Sets the number of images which can be accpeted by the application at one time */ bool TwainIface::SetImageCount(TW_INT16 nCount) { if(SetCapability(CAP_XFERCOUNT,(TW_UINT16)nCount,true)) { m_nImageCount = nCount; return true; } else { if(GetRC() == TWRC_CHECKSTATUS) { TW_UINT32 count; if(GetCapability(CAP_XFERCOUNT, count)) { nCount = (TW_INT16)count; if(SetCapability(CAP_XFERCOUNT, nCount)) { m_nImageCount = nCount; return true; } } } } return false; }
/* ************************************************************************************** * Function Name: Handler_Recv * Description: Receive Packet from MQTT Server * Input : char * const topic, * void* const data, * const size_t datalen * Output: void *pRev1, * void* pRev2 * Return: None * ***************************************************************************************/ void HANDLER_API Handler_Recv( char * const topic, void* const data, const size_t datalen, void *pRev1, void* pRev2 ) { int commCmd = unknown_cmd; char errorStr[128] = {0}; RemoteKVMLog(g_loghandle, Normal, " %s>Recv Topic [%s] Data %s", strPluginName, topic, (char*) data ); printf(" >Recv Topic [%s] Data %s", topic, (char*) data ); if(!ParseReceivedData(data, datalen, &commCmd)) return; switch(commCmd) { case kvm_get_capability_req: { GetCapability(); break; } case kvm_get_vnc_mode_req: { GetVNCMode(); break; } case kvm_get_connect_params_req: { kvm_vnc_server_start_params kvmVNCServerStartParms; memset(&kvmVNCServerStartParms, 0, sizeof(kvm_vnc_server_start_params)); if(ParseKVMRecvCmd((char*)data, &kvmVNCServerStartParms)) { KVMGetConnectParams(&kvmVNCServerStartParms); } else { memset(errorStr, 0, sizeof(errorStr)); sprintf(errorStr, "Command(%d) parse error!",kvm_get_connect_params_req); { char * errorRepJsonStr = NULL; int jsonStrlen = Parser_PackKVMErrorRep(errorStr, &errorRepJsonStr); if(jsonStrlen > 0 && errorRepJsonStr != NULL) { g_sendcbf(&g_PluginInfo, kvm_error_rep, errorRepJsonStr, strlen(errorRepJsonStr)+1, NULL, NULL); } if(errorRepJsonStr)free(errorRepJsonStr); } } break; } default: { char * errorRepJsonStr = NULL; int jsonStrlen = Parser_PackKVMErrorRep("Unknown cmd!", &errorRepJsonStr); if(jsonStrlen > 0 && errorRepJsonStr != NULL) { g_sendcbf(&g_PluginInfo, kvm_error_rep, errorRepJsonStr, strlen(errorRepJsonStr)+1, NULL, NULL); } if(errorRepJsonStr)free(errorRepJsonStr); break; } } }
/* Queries the capability of the Twain Data Source */ BOOL CTwain::GetCapability(TW_UINT16 cap,TW_UINT32& value) { TW_CAPABILITY twCap; if(GetCapability(twCap,cap)) { pTW_ONEVALUE pVal; pVal = (pTW_ONEVALUE )GlobalLock(twCap.hContainer); if(pVal) { value = pVal->Item; GlobalUnlock(pVal); GlobalFree(twCap.hContainer); return TRUE; } } return FALSE; }
/** Queries the capability of the Twain Data Source */ bool TwainIface::GetCapability(TW_UINT16 cap, TW_UINT32& value) { TW_CAPABILITY twCap; if(GetCapability(twCap, cap)) { pTW_ONEVALUE pVal; pVal = (pTW_ONEVALUE )GlobalLock(twCap.hContainer); if(pVal) { value = pVal->Item; GlobalUnlock(pVal); GlobalFree(twCap.hContainer); return true; } } return false; }
/** Sets the number of images which can be accpeted by the application at one time */ bool KSaneWidgetPrivate::SetImageCount(TW_INT16 nCount) { if(SetCapability(CAP_XFERCOUNT,(TW_UINT16)nCount,true)) { m_nImageCount = nCount; return true; } else { if(m_returnCode == TWRC_CHECKSTATUS) { TW_UINT32 count; if(GetCapability(CAP_XFERCOUNT, count)) { nCount = (TW_INT16)count; if(SetCapability(CAP_XFERCOUNT, nCount)) { m_nImageCount = nCount; return true; } } } } return false; }
/************************************************************** nRotation : Rotation direction is defined at run time 0 -- No rotation 1 -- 90 degree counter clockwise (default) 2 -- 180 degree rotation (upside-down) 3 -- 90 degree clockwise -1 -- flip left-right -2 -- flip and rotate 90 degree cnt clk -3 -- flip and rotate 180 degree -4 -- flip and rotate 270 degree **************************************************************/ int32 ColorConvertBase::Init(int32 Src_width, int32 Src_height, int32 Src_pitch, int32 Dst_width, int32 Dst_height, int32 Dst_pitch, int32 nRotation) { /* check the followings, must be multiple of 2 */ if ((Src_pitch&1) || (Dst_pitch&1) || (Dst_height&1) || (Src_height&1) || (Src_width&1)) { return 0; } _mInitialized = false; _mSrc_mheight = Src_height; _mRotation = nRotation; _mDisp.src_pitch = _mSrc_pitch = Src_pitch; _mDisp.dst_pitch = _mDst_pitch = Dst_pitch; _mDisp.src_width = _mSrc_width = Src_width; _mDisp.src_height = _mSrc_height = Src_height; _mDisp.dst_width = _mDst_width = Dst_width; _mDisp.dst_height = _mDst_height = Dst_height; /* Check support for rotation */ if (_mRotation&0x1) { if (!(GetCapability()&CCSUPPORT_ROTATION)) { return 0; } } _mIsFlip = false; if (_mRotation & 0x4) { _mIsFlip = true; _mRotation -= 4; } //For now, we only support the zoom ratio <=3 if (_mRotation&0x1) { if (((Src_width*3) < Dst_height) || ((Src_height*3) < Dst_width)) { return 0; } } else { if (((Src_width*3) < Dst_width) || ((Src_height*3) < Dst_height)) { return 0; } } if (_mRowPix) { OSCL_ARRAY_DELETE(_mRowPix); } if (_mColPix) { OSCL_ARRAY_DELETE(_mColPix); } _mRowPix = NULL; _mColPix = NULL; if ((_mRotation&0x1) == 0) { /* no rotation */ if ((_mDst_width != _mSrc_width) || (_mDst_height != _mSrc_height)) { /* scaling */ //calulate the Row int32 leavecode = 0; OSCL_TRY(leavecode, _mRowPix = OSCL_ARRAY_NEW(uint8, _mSrc_width); _mColPix = OSCL_ARRAY_NEW(uint8, _mSrc_height); ); OSCL_FIRST_CATCH_ANY(leavecode, if (_mRowPix) { OSCL_ARRAY_DELETE(_mRowPix); } if (_mColPix) { OSCL_ARRAY_DELETE(_mColPix); } _mRowPix = NULL; _mColPix = NULL; return 0; );