ESign
>w## Notice
> * please include the header file "mmi_esignature.h" when you need to get esign data
`#include "mmi_esignature.h"`
>i## mmi_eSign_InnerSign
### Prototype
`int mmi_eSign_InnerSign(unsigned char *pCode, unsigned int iCodeLen, int timeout);`
### Function
* Draw the signature data on the screen
### Parameter
|Name|Type|description|
|-|-|-|
|pCode|unsigned char *|condition code|
|iCodeLen|unsigned int|condition code len|
|timeout|int|timeout|
### Retval
|Value|Type|Description|
|-|-|-|
|=0|int|success|
|<0|int|fail|
>i## mmi_eSign_CompressImage
### Prototype
`int mmi_eSign_CompressImage(const char *pDstFileName,unsigned char* pOutData,unsigned int* pOutLen);`
### Function
* Compress the signature data to file
### Parameter
|Name|Type|description|
|-|-|-|
|pDstFileName|const char *| file name|
|pOutData|unsigned char*| Compress data|
|pOutLen|unsigned int*|Compress data len|
### Retval
|Value|Type|Description|
|-|-|-|
|=0|int|success|
|<0|int|fail|
>i## mmi_eSign_CompressData
### Prototype
`int mmi_eSign_CompressData(unsigned char* pOutData,unsigned int* pOutLen);`
### Function
* Compress the signature data
### Parameter
|Name|Type|description|
|-|-|-|
|pOutData|unsigned char*| Compress data|
|pOutLen|unsigned int*|Compress data len|
### Retval
|Value|Type|Description|
|-|-|-|
|=0|int|success|
|<0|int|fail|
>i## mmi_eSign_UnCompressImage
### Prototype
`int mmi_eSign_UnCompressImage(const char *pSrcFileName,unsigned char*pOutBuff,unsigned int* pOutLen);`
### Function
* UnCompress the signature file
### Parameter
|Name|Type|description|
|-|-|-|
|pSrcFileName|const char *| file name|
|pOutBuff|unsigned char*|unCompress data|
|pOutLen|unsigned int*|unCompress data len|
### Retval
|Value|Type|Description|
|-|-|-|
|=0|int|success|
|<0|int|fail|
>i## mmi_eSign_UnCompressData
### Prototype
`int mmi_eSign_UnCompressData(unsigned char *pInData,unsigned int uiInLen,unsigned char*pOutBuff,unsigned int* pOutLen);`
### Function
* UnCompress the signature data
### Parameter
|Name|Type|description|
|-|-|-|
|pInData|unsigned char *|unCompress data|
|uiInLen|unsigned int |unCompress data len|
|pOutBuff|unsigned char*|unCompress out data|
|pOutLen|unsigned int*|unCompress out len|
### Retval
|Value|Type|Description|
|-|-|-|
|=0|int|success|
|<0|int|fail|
>s## Example
```
#define ESIGN_BUFF_LEN (1024*5)
#define ESIGN_JPG_BUFF_LEN (2500)
int esign_demo(void)
{
int iRet = SUCCESS;
char acDisp[128] = {0};
unsigned char *pEsignjpgData = NULL;
unsigned char *pEsignBmpData = NULL;
unsigned int uiEsignJpgDataLen = 0;
unsigned int uiEsignBmpDataLen = 0;
ts_printer_para stPrinterPara;
pEsignjpgData = malloc(ESIGN_JPG_BUFF_LEN);
if(NULL == pEsignjpgData)
{
strcpy(acDisp,"esgin jpg buff malloc fail!");
goto ERR;
}
pEsignBmpData = malloc(ESIGN_BUFF_LEN);
if(NULL == pEsignBmpData)
{
strcpy(acDisp,"esgin bmp buff malloc fail!");
goto ERR;
}
memset(pEsignjpgData, 0, ESIGN_JPG_BUFF_LEN);
memset(pEsignBmpData, 0, ESIGN_BUFF_LEN);
mmi_clearLine(DISP_ClearALL);
mmi_display(DISP_Line1, DISP_HCenter, "sign in screen box");
iRet = mmi_eSign_InnerSign("12345678", 8, 60);
if (SUCCESS != iRet)
{
sprintf(acDisp, "inner sign return:%d", iRet);
goto ERR;
}
iRet = mmi_eSign_CompressData(pEsignjpgData,&uiEsignJpgDataLen);
if (SUCCESS != iRet)
{
sprintf(acDisp, "esign compress data return:%d", iRet);
goto ERR;
}
iRet = mmi_eSign_UnCompressData(pEsignjpgData, uiEsignJpgDataLen, pEsignBmpData, &uiEsignBmpDataLen);
if (SUCCESS != iRet)
{
sprintf(acDisp, "esign UnCompressData data return:%d", iRet);
goto ERR;
}
iRet = printer_check();
if (PRINTER_RET_OK != iRet)
{
sprintf(acDisp, "printer_check fail return:%d", iRet);
goto ERR;
}
iRet = printer_open();
if (PRINTER_RET_OK != iRet)
{
sprintf(acDisp, "printer_open fail return:%d", iRet);
goto ERR;
}
memset(&stPrinterPara, 0, sizeof(ts_printer_para));
iRet = printer_clear();
if (PRINTER_RET_OK != iRet)
{
sprintf(acDisp, "printer_clear fail return:%d", iRet);
goto ERR;
}
iRet = printer_get_para(&stPrinterPara);
if (PRINTER_RET_OK != iRet)
{
sprintf(acDisp, "printer_get_para fail return:%d", iRet);
goto ERR;
}
iRet = printer_add_bmp_with_param(&stPrinterPara, (char*)pEsignBmpData, uiEsignBmpDataLen, 0);
if (PRINTER_RET_OK != iRet)
{
sprintf(acDisp, "printer_add_bmp_path_with_param fail return:%d", iRet);
goto ERR;
}
iRet = printer_print();
if (iRet != PRINTER_RET_OK)
{
sprintf(acDisp, "printer_print fail return:%d", iRet);
goto ERR;
}
printer_feed(32 * 3);
printer_close();
ERR:
if (strlen(acDisp) > 0)
{
mmi_clearLine(DISP_ClearALL);
mmi_display(DISP_VCenter, DISP_HCenter, acDisp);
mmi_inputWaitKeypress(3);
}
if (NULL != pEsignjpgData)
{
free(pEsignjpgData);
}
if (NULL != pEsignBmpData)
{
free(pEsignBmpData);
}
return iRet;
}
```