📄 ltkimagewriter.cpp
字号:
/**********************************************************************************
* AUTHOR : Bharath A
* DATE : 22-FEB-2005
* NAME : drawRawInkFileToImage
* DESCRIPTION : The function creates LTKTraceGroup from the specified data file and draws it to image file with specified width,height,color and offset. If offset not equal to zero, the image would be in the trace order.
* ARGUMENTS :
* fileName path to the datafile
* imgFileName name of the file that is to be created to draw the image
* imgWidth width of the image
* imgHeight height of the image
*
* RETURNS :
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
void LTKImageWriter::drawRawInkFileToImage(const string fileName, const string imgFileName,
int imgWidth,int imgHeight)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKImageWriter::drawRawInkFileToImage(const string, const string,int,int)" << endl;
LTKTraceGroup traceGroup;
LTKCaptureDevice captureDevice;
LTKScreenContext screenContext;
string strFileName(fileName);
try
{
LTKInkFileReader::readRawInkFile(strFileName,traceGroup,captureDevice,screenContext);
}
catch(LTKException e)
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< EINK_FILE_OPEN <<":"<< getErrorMessage(EINK_FILE_OPEN)
<<"LTKImageWriter::drawRawInkFileToImage(const string, const string,int,int)" <<endl;
errorCode = EINK_FILE_OPEN;
}
drawLTKTraceGroupToImage(traceGroup,imgFileName,imgWidth,imgHeight);
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKImageWriter::drawRawInkFileToImage(const string, const string,int,int)" << endl;
}
/**********************************************************************************
* AUTHOR : Bharath A
* DATE : 22-FEB-2005
* NAME : drawRawInkFileToImage
* DESCRIPTION : The function creates LTKTraceGroup from the specified data file and draws it to image file with specified color and offset. The width and height would be determined from the trace group.
* ARGUMENTS :
* fileName path to the datafile
* imgFileName name of the file that is to be created to draw the image
*
* RETURNS :
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
void LTKImageWriter::drawRawInkFileToImage(const string fileName, const string imgFileName)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKImageWriter::drawRawInkFileToImage(const string, const string)" << endl;
LTKTraceGroup traceGroup;
LTKCaptureDevice captureDevice;
LTKScreenContext screenContext;
string strFileName(fileName);
try
{
LTKInkFileReader::readRawInkFile(strFileName,traceGroup,captureDevice,screenContext);
}
catch(LTKException e)
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< EINK_FILE_OPEN <<":"<< getErrorMessage(EINK_FILE_OPEN)
<<"LTKImageWriter::drawRawInkFileToImage(const string, const string)" <<endl;
errorCode = EINK_FILE_OPEN;
}
drawLTKTraceGroupToImage(traceGroup,imgFileName);
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKImageWriter::drawRawInkFileToImage(const string, const string)" << endl;
}
/**********************************************************************************
* AUTHOR : Bharath A
* DATE : 22-FEB-2005
* NAME : drawRawInkFileToImage
* DESCRIPTION : The function draws LTKTraceGroup to image file with specified color and offset. The size specified is the bound on larger dimension and the trace group is normalized to maintain the aspect ratio.
* ARGUMENTS :
* fileName path to the data file
* imgFileName name of the file that is to be created to draw the image
* size bound on larger dimension
*
* RETURNS :
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
void LTKImageWriter::drawRawInkFileToImage(const string fileName,const string imgFileName,int size)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKImageWriter::drawRawInkFileToImage(const string,const string,int)" << endl;
LTKTraceGroup traceGroup;
LTKCaptureDevice captureDevice;
LTKScreenContext screenContext;
string strFileName(fileName);
try
{
LTKInkFileReader::readRawInkFile(strFileName,traceGroup,captureDevice,screenContext);
}
catch(LTKException e)
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< EINK_FILE_OPEN <<":"<< getErrorMessage(EINK_FILE_OPEN)
<<"LTKImageWriter::drawRawInkFileToImage(const string,const string,int)" <<endl;
errorCode = EINK_FILE_OPEN;
}
drawLTKTraceGroupToImage(traceGroup,imgFileName,size);
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKImageWriter::drawRawInkFileToImage(const string,const string,int)" << endl;
}
/**********************************************************************************
* AUTHOR : Bharath A
* DATE : 22-FEB-2005
* NAME : drawUnipenFileToImage
* DESCRIPTION : The function creates LTKTraceGroup from the specified unipen data file and draws it to image file with specified width,height,color and offset. If offset not equal to zero, the image would be in the trace order.
* ARGUMENTS :
* unipenFileName path to the datafile
* imgFileName name of the file that is to be created to draw the image
* imgWidth width of the image
* imgHeight height of the image
*
* RETURNS :
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
void LTKImageWriter::drawUnipenFileToImage(const string unipenFileName,const string imgFileName,int imgWidth,int imgHeight)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKImageWriter::drawUnipenFileToImage(const string,const string,int,int)" << endl;
LTKTraceGroup traceGroup;
LTKCaptureDevice captureDevice;
LTKScreenContext screenContext;
string strFileName(unipenFileName);
try
{
LTKInkFileReader::readUnipenInkFile(strFileName,traceGroup,captureDevice,screenContext);
}
catch(LTKException e)
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< EINK_FILE_OPEN <<":"<< getErrorMessage(EINK_FILE_OPEN)
<<"LTKImageWriter::drawUnipenFileToImage(const string,const string,int,int)" <<endl;
errorCode = EINK_FILE_OPEN;
}
drawLTKTraceGroupToImage(traceGroup,imgFileName,imgWidth,imgHeight);
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKImageWriter::drawUnipenFileToImage(const string,const string,int,int)" << endl;
}
/**********************************************************************************
* AUTHOR : Bharath A
* DATE : 22-FEB-2005
* NAME : drawUnipenFileToImage
* DESCRIPTION : The function creates LTKTraceGroup from the specified unipen data file and draws it to image file with specified color and offset. The width and height would be determined from the trace group.
* ARGUMENTS :
* unipenFileName path to the datafile
* imgFileName name of the file that is to be created to draw the image
*
* RETURNS :
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
void LTKImageWriter::drawUnipenFileToImage(const string& unipenFileName,const string& imgFileName)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKImageWriter::drawUnipenFileToImage(const string&,const string&)" << endl;
LTKTraceGroup traceGroup;
LTKCaptureDevice captureDevice;
LTKScreenContext screenContext;
string strFileName(unipenFileName);
try
{
LTKInkFileReader::readUnipenInkFile(strFileName,traceGroup,captureDevice,screenContext);
}
catch(LTKException e)
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< EINK_FILE_OPEN <<":"<< getErrorMessage(EINK_FILE_OPEN)
<<"LTKImageWriter::drawUnipenFileToImage(const string&,const string&)" <<endl;
errorCode = EINK_FILE_OPEN;
}
drawLTKTraceGroupToImage(traceGroup,imgFileName);
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKImageWriter::drawUnipenFileToImage(const string&,const string&)" << endl;
}
/**********************************************************************************
* AUTHOR : Bharath A
* DATE : 22-FEB-2005
* NAME : drawUnipenFileToImage
* DESCRIPTION : The function creates LTKTraceGroup from the unipen data file specified and draws it to image file with specified color and offset. The size specified is the bound on larger dimension and the trace group is normalized to maintain the aspect ratio.
* ARGUMENTS :
* unipenFileName path to the unipen data file
* imgFileName name of the file that is to be created to draw the image
* size bound on larger dimension
*
* RETURNS :
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
void LTKImageWriter::drawUnipenFileToImage(const string& unipenFileName,const string& imgFileName,int size)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKImageWriter::drawUnipenFileToImage(const string&,const string&,int)" << endl;
LTKTraceGroup traceGroup;
LTKCaptureDevice captureDevice;
LTKScreenContext screenContext;
string strFileName(unipenFileName);
try
{
LTKInkFileReader::readUnipenInkFile(strFileName,traceGroup,captureDevice,screenContext);
}
catch(LTKException e)
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< EINK_FILE_OPEN <<":"<< getErrorMessage(EINK_FILE_OPEN)
<<"LTKImageWriter::drawUnipenFileToImage(const string&,const string&,int)" <<endl;
errorCode = EINK_FILE_OPEN;
}
drawLTKTraceGroupToImage(traceGroup,imgFileName,size);
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKImageWriter::drawUnipenFileToImage(const string&,const string&,int)" << endl;
}
/**********************************************************************************
* AUTHOR : Bharath A
* DATE : 22-FEB-2005
* NAME : drawUnipenFileToImageWithBB
* DESCRIPTION : The function creates LTKTraceGroup from the unipen data file specified and draws it to image file with specified color and offset. The size specified is the bound on larger dimension and the trace group is normalized to maintain the aspect ratio.The bounding box of the image is also drawn to show relative position.
* ARGUMENTS :
* unipenFileName path to the unipen data file
* imgFileName name of the file that is to be created to draw the image
* size bound on larger dimension
*
* RETURNS :
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
void LTKImageWriter::drawUnipenFileToImageWithBB(const string& unipenFileName,const string& imgFileName,int size)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKImageWriter::drawUnipenFileToImageWithBB()" << endl;
LTKTraceGroup traceGroup;
string strFileName(unipenFileName);
LTKCaptureDevice captureDevice;
LTKScreenContext screenContext;
try
{
LTKInkFileReader::readUnipenInkFile(strFileName,traceGroup,captureDevice,screenContext);
}
catch(LTKException e)
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< EINK_FILE_OPEN <<":"<< getErrorMessage(EINK_FILE_OPEN)
<<"LTKImageWriter::drawUnipenFileToImageWithBB()" <<endl;
errorCode = EINK_FILE_OPEN;
}
drawLTKTraceGroupToImageWithBB(traceGroup,screenContext,imgFileName,size);
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKImageWriter::drawUnipenFileToImageWithBB()" << endl;
}
/**********************************************************************************
* AUTHOR : Bharath A
* DATE : 22-FEB-2005
* NAME : showStartingPoint
* DESCRIPTION : The set function for showing the starting point of each stroke
* ARGUMENTS :
* toShow flag to show the starting point
* RETURNS :
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
void LTKImageWriter::showStartingPoint(bool toShow)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKImageWriter::showStartingPoint()" << endl;
m_showSP=toShow;
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKImageWriter::showStartingPoint()" << endl;
}
/**********************************************************************************
* AUTHOR : Bharath A
* DATE : 22-FEB-2005
* NAME : findMinXOfTrace
* DESCRIPTION : The function finds the minimum x value of the given trace.
* ARGUMENTS :
* trace input trace
*
* RETURNS : minimum value of x
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
int LTKImageWriter::findMinXOfTrace(const LTKTrace& trace,float& minX)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKImageWriter::findMinXOfTrace(const LTKTrace&,float&)" << endl;
minX=numeric_limits<float>::infinity();
for(int i=0;i<trace.getNumberOfPoints();i++){
vector<float> point;
trace.getPointAt(i, point);
if(point[0]<minX){
minX=point[0];
}
}
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKImageWriter::findMinXOfTrace(const LTKTrace&,float&)" << endl;
return SUCCESS;
}
/**********************************************************************************
* AUTHOR : Bharath A
* DATE : 22-FEB-2005
* NAME : findMaxXOfTrace
* DESCRIPTION : The function finds the maximum x value of the given trace.
* ARGUMENTS :
* trace input trace
*
* RETURNS : maximum value of x
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
int LTKImageWriter::findMaxXOfTrace(const LTKTrace& trace,float& maxX)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKImageWriter::findMaxXOfTrace(const LTKTrace&,float&)" << endl;
maxX = -FLT_MAX;
for(int i=0;i<trace.getNumberOfPoints();i++){
vector<float> point;
trace.getPointAt(i, point);
if(point[0]>maxX){
maxX=point[0];
}
}
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKImageWriter::findMaxXOfTrace(const LTKTrace&,float&)" << endl;
return SUCCESS;
}
/**********************************************************************************
* AUTHOR : Bharath A
* DATE : 22-FEB-2005
* NAME : drawPoint
* DESCRIPTION : The function makes entries in the pixels array for the specified x,y and color.
* ARGUMENTS :
* x,y coordinates of the point to be drawn
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -