huago-corrcet_tools/HuaGoCorrect/JpegBuffer.cpp

84 lines
1.6 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "StdAfx.h"
#include "JpegBuffer.h"
#include "jpeglib.h"
//#include "twain.h"
#include "filetools.h"
#include "PublicFunc.h"
using namespace std;
JpegBuffer::JpegBuffer()
{
}
JpegBuffer::JpegBuffer(cv::Mat buffer, int color_type,int side,int mFilter)
{
this->m_buffer = buffer;
this->m_color_type=color_type;
this->m_side=side;
this->m_mFilter=mFilter;
}
JpegBuffer::~JpegBuffer(void)
{
}
unsigned char* JpegBuffer::getBuffer()
{
return m_buffer.data;
}
cv::Mat JpegBuffer::buffer()
{
return m_buffer;
}
int JpegBuffer::getSize()
{
return m_buffer.cols;
}
cv::Mat JpegBuffer::getMat( int pixType)
{
JpegLib jl;
//cv::Mat image = jl.decode(m_buffer, 6);//oixtype
StopWatch sw;
//XdPrint("buffer size is :%d ==========================\n",getSize());
cv::Mat image = jl.decode(m_buffer, pixType);//oixtype
XdPrint(L"Decode Image time epleased :%lf ==========================\n",sw.elapsed_ms());
//XdPrint("==image col is :%d, image row is :%d, image size is :%d===\n",image.cols, image.rows, image.size);
//FileTools::write_log("D:/1.txt",)
//cv::InputArray arr(m_buffer);
//
//cv::Mat image1=imdecode(arr,m_color_type==TWPT_RGB?CV_LOAD_IMAGE_COLOR:CV_LOAD_IMAGE_GRAYSCALE);
//cv::imwrite("0.bmp",image1);
//char str[256];
//sprintf(str, "%lf", sw.time_run());
//string res=str;
//FileTools::write_log("D:/1.txt",res);
//0 ÕýÃæ 1·´Ãæ
//if (!backRotate&&(m_side==0||m_side==1))
//{
// cv::Rect rect(0, m_side == 0 ? 0 : gap, image.cols,(image.rows-gap));
// image = image(rect);
//}
return image.clone();
}
int JpegBuffer::getMFilter()
{
return m_mFilter;
}
int JpegBuffer::getSide()
{
return m_side;
}