|
|
|
|
// FastLookUpDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
#include "FastLookUpDlg.h"
|
|
|
|
|
#include "afxdialogex.h"
|
|
|
|
|
#include "GlobalFunc.h"
|
|
|
|
|
#include "CvvImage.h"
|
|
|
|
|
#include "ImgShowDlg.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CFastLookUpDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC(CFastLookUpDlg, CDialogEx)
|
|
|
|
|
|
|
|
|
|
CFastLookUpDlg::CFastLookUpDlg(CWnd* pParent /*=NULL*/)
|
|
|
|
|
: CDialogEx(CFastLookUpDlg::IDD, pParent)
|
|
|
|
|
{
|
|
|
|
|
m_SrcFrame = nullptr;
|
|
|
|
|
m_iPage = 0;
|
|
|
|
|
m_ptrParent = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CFastLookUpDlg::~CFastLookUpDlg()
|
|
|
|
|
{
|
|
|
|
|
m_ptrParent = nullptr;
|
|
|
|
|
|
|
|
|
|
// <20>鱨<EFBFBD><E9B1A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if(m_ImgStruDeque.size() > 0)
|
|
|
|
|
{
|
|
|
|
|
for (size_t i = 0; i < m_ImgStruDeque.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
SAFE_DELETE_ARRAY(m_ImgStruDeque[i].buff);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_ImgStruDeque.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_SrcFrame != NULL)
|
|
|
|
|
{
|
|
|
|
|
cvReleaseImage(&m_SrcFrame);
|
|
|
|
|
m_SrcFrame = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CFastLookUpDlg::DoDataExchange(CDataExchange* pDX)
|
|
|
|
|
{
|
|
|
|
|
CDialogEx::DoDataExchange(pDX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CFastLookUpDlg, CDialogEx)
|
|
|
|
|
ON_BN_CLICKED(IDC_BTN_PRE_PAGE, &CFastLookUpDlg::OnBnClickedBtnPrePage)
|
|
|
|
|
ON_BN_CLICKED(IDC_BTN_NEXT_PAGE, &CFastLookUpDlg::OnBnClickedBtnNextPage)
|
|
|
|
|
ON_WM_PAINT()
|
|
|
|
|
ON_WM_LBUTTONDBLCLK()
|
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CFastLookUpDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
void CFastLookUpDlg::SetParentPt(void *pt)
|
|
|
|
|
{
|
|
|
|
|
m_ptrParent = pt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void CFastLookUpDlg::SetImgData(const ImgStru &img)
|
|
|
|
|
{
|
|
|
|
|
if(m_ImgStruDeque.size() >= 18)
|
|
|
|
|
{
|
|
|
|
|
std::deque<ImgStru>::iterator iter; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
iter = m_ImgStruDeque.begin();
|
|
|
|
|
|
|
|
|
|
// <20>ͷ<EFBFBD>ָ<EFBFBD><D6B8>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
|
|
|
|
SAFE_DELETE_ARRAY(iter->buff);
|
|
|
|
|
iter->buff = NULL;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>
|
|
|
|
|
m_ImgStruDeque.pop_front();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ImgStru local; // <20>ֲ<EFBFBD><D6B2><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CloneImgStru(img, local); // <20><><EFBFBD>ȸ<EFBFBD><C8B8><EFBFBD>
|
|
|
|
|
|
|
|
|
|
m_ImgStruDeque.push_back(local); // <20><><EFBFBD>ӣ<EFBFBD>dz<EFBFBD><C7B3><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
// <20>Ӷ<EFBFBD>ʹlocal<61><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵĽṹ<C4BD><E1B9B9><EFBFBD><EFBFBD>ΪҰָ<D2B0>룻
|
|
|
|
|
local.buff = NULL;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><>ʾͼ<CABE><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int CFastLookUpDlg::ShowImgData()
|
|
|
|
|
{
|
|
|
|
|
if (m_ImgStruDeque.empty() == true)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int showCount = 0;
|
|
|
|
|
|
|
|
|
|
// <20><>ͼ<EFBFBD><CDBC>С<EFBFBD><D0A1>9<EFBFBD><39>ʱ<EFBFBD><CAB1>һ<EFBFBD><D2BB><EFBFBD>ڵ<EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
if (m_ImgStruDeque.size() <= 9)
|
|
|
|
|
{
|
|
|
|
|
m_iPage = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_iPage == 0)
|
|
|
|
|
{
|
|
|
|
|
if (m_ImgStruDeque.size() >= 9)
|
|
|
|
|
{
|
|
|
|
|
showCount = 9;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
showCount = m_ImgStruDeque.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < showCount; i++)
|
|
|
|
|
{
|
|
|
|
|
// <20><>ʾͼ<CABE><CDBC>
|
|
|
|
|
showOneImg(i, m_ImgStruDeque[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER1)->SetWindowText("1");
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER2)->SetWindowText("2");
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER3)->SetWindowText("3");
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER4)->SetWindowText("4");
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER5)->SetWindowText("5");
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER6)->SetWindowText("6");
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER7)->SetWindowText("7");
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER8)->SetWindowText("8");
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER9)->SetWindowText("9");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (m_iPage == 1)
|
|
|
|
|
{
|
|
|
|
|
if (m_ImgStruDeque.size() > 9)
|
|
|
|
|
{
|
|
|
|
|
showCount = m_ImgStruDeque.size() - 9;
|
|
|
|
|
|
|
|
|
|
for (size_t i = 9; i < m_ImgStruDeque.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
// <20><>ʾͼ<CABE><CDBC>
|
|
|
|
|
showOneImg(i, m_ImgStruDeque[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER1)->SetWindowText("10");
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER2)->SetWindowText("11");
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER3)->SetWindowText("12");
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER4)->SetWindowText("13");
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER5)->SetWindowText("14");
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER6)->SetWindowText("15");
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER7)->SetWindowText("16");
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER8)->SetWindowText("17");
|
|
|
|
|
GetDlgItem(IDC_STATIC_ORDER9)->SetWindowText("18");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return showCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><>ʾһ<CABE><D2BB>ͼ<EFBFBD><CDBC>
|
|
|
|
|
void CFastLookUpDlg::showOneImg(int IDtag, const ImgStru &imgStru)
|
|
|
|
|
{
|
|
|
|
|
if (IDtag < 0 || IDtag > 17)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int nID = 0;
|
|
|
|
|
|
|
|
|
|
switch(IDtag)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
case 9:
|
|
|
|
|
nID = IDC_STATIC_IMG1;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
case 10:
|
|
|
|
|
nID = IDC_STATIC_IMG2;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
case 11:
|
|
|
|
|
nID = IDC_STATIC_IMG3;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
case 12:
|
|
|
|
|
nID = IDC_STATIC_IMG4;
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
case 13:
|
|
|
|
|
nID = IDC_STATIC_IMG5;
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
case 14:
|
|
|
|
|
nID = IDC_STATIC_IMG6;
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
case 15:
|
|
|
|
|
nID = IDC_STATIC_IMG7;
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
case 16:
|
|
|
|
|
nID = IDC_STATIC_IMG8;
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
case 17:
|
|
|
|
|
nID = IDC_STATIC_IMG9;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int imgWidth = imgStru.ImgWidth;
|
|
|
|
|
int imgHeight = imgStru.ImgHeight;
|
|
|
|
|
int nBitCount = imgStru.bitcount;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><D5B9>4<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
|
|
|
|
|
int lineByte = (imgWidth * nBitCount / 8 + 3) / 4 * 4;
|
|
|
|
|
|
|
|
|
|
// λͼ<CEBB><CDBC><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>С
|
|
|
|
|
unsigned int imgBufSize = static_cast<unsigned int>(imgHeight * lineByte);
|
|
|
|
|
|
|
|
|
|
if (imgWidth > 0
|
|
|
|
|
&& imgHeight > 0
|
|
|
|
|
&& imgStru.buff != NULL
|
|
|
|
|
&& (nBitCount == 8 || nBitCount == 24))
|
|
|
|
|
{
|
|
|
|
|
// <20><>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD> m_SrcFrame <20><><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
if (m_SrcFrame != NULL) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>б仯 ֱ<>Ӹ<EFBFBD><D3B8><EFBFBD>ԭʼͼ<CABC><CDBC><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ͼ<EFBFBD><CDBC>
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><D4B7><EFBFBD><EFBFBD>˱仯<CBB1><E4BBAF><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ͷ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD>ٴ<EFBFBD><D9B4><EFBFBD>ͼ<EFBFBD><CDBC>
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>1
|
|
|
|
|
if ((m_SrcFrame->width == imgWidth) &&
|
|
|
|
|
(m_SrcFrame->height == imgHeight) &&
|
|
|
|
|
(m_SrcFrame->depth * m_SrcFrame->nChannels == nBitCount) )
|
|
|
|
|
{
|
|
|
|
|
// <20>ڴ渴<DAB4>ƻ<EFBFBD><C6BB><EFBFBD>
|
|
|
|
|
int RealLineByte = (imgWidth * nBitCount / 8);
|
|
|
|
|
|
|
|
|
|
if (RealLineByte == lineByte)
|
|
|
|
|
{
|
|
|
|
|
memcpy(m_SrcFrame->imageData, imgStru.buff, imgBufSize); // ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < imgHeight; i++)
|
|
|
|
|
{
|
|
|
|
|
memcpy(m_SrcFrame->imageData + i * lineByte, imgStru.buff + i * RealLineByte, RealLineByte);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // <20><><EFBFBD><EFBFBD>2
|
|
|
|
|
{
|
|
|
|
|
// <20>ͷ<EFBFBD>ͼ<EFBFBD><CDBC>
|
|
|
|
|
cvReleaseImage(&m_SrcFrame);
|
|
|
|
|
m_SrcFrame = NULL;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>
|
|
|
|
|
m_SrcFrame = cvCreateImage(cvSize(imgWidth, imgHeight), 8, nBitCount/8); // <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
|
|
|
|
|
|
|
|
|
if (m_SrcFrame != NULL) // <20><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
// <20>ڴ渴<DAB4>ƻ<EFBFBD><C6BB><EFBFBD>
|
|
|
|
|
int RealLineByte = (imgWidth * nBitCount / 8);
|
|
|
|
|
|
|
|
|
|
if (RealLineByte == lineByte)
|
|
|
|
|
{
|
|
|
|
|
memcpy(m_SrcFrame->imageData, imgStru.buff, imgBufSize); // ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < imgHeight; i++)
|
|
|
|
|
{
|
|
|
|
|
memcpy(m_SrcFrame->imageData + i * lineByte, imgStru.buff + i * RealLineByte, RealLineByte);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ͼ<EFBFBD><CDBC> <20><>Ҫ<EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>ͼ<EFBFBD><CDBC>
|
|
|
|
|
{
|
|
|
|
|
m_SrcFrame = cvCreateImage(cvSize(imgWidth, imgHeight), 8, nBitCount/8); // <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
|
|
|
|
|
|
|
|
|
if (m_SrcFrame != NULL) // <20><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
// <20>ڴ渴<DAB4>ƻ<EFBFBD><C6BB><EFBFBD>
|
|
|
|
|
int RealLineByte = (imgWidth * nBitCount / 8);
|
|
|
|
|
|
|
|
|
|
if (RealLineByte == lineByte)
|
|
|
|
|
{
|
|
|
|
|
memcpy(m_SrcFrame->imageData, imgStru.buff, imgBufSize); // ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < imgHeight; i++)
|
|
|
|
|
{
|
|
|
|
|
memcpy(m_SrcFrame->imageData + i * lineByte, imgStru.buff + i * RealLineByte, RealLineByte);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><>ʾͼ<CABE><CDBC>
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> pictrue <20>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD>ڵľ<DAB5><C4BE><EFBFBD>
|
|
|
|
|
CWnd *pWnd = NULL;
|
|
|
|
|
pWnd = GetDlgItem(nID);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|
|
|
|
if (pWnd == NULL)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><>ȡͼ<C8A1><CDBC><EFBFBD>ؼ<EFBFBD>HDC
|
|
|
|
|
CDC *pDC = NULL; // <20><><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>ʱ<EFBFBD><CAB1>Ҫ<EFBFBD>ͷ<EFBFBD> ReleaseDC(pDC);
|
|
|
|
|
pDC = pWnd->GetDC();
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|
|
|
|
if (pDC == NULL)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HDC hdc = NULL;
|
|
|
|
|
hdc = pDC->GetSafeHdc();
|
|
|
|
|
|
|
|
|
|
if (hdc == NULL)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><>ǰͼ<C7B0><CDBC><EFBFBD>ߴ<EFBFBD>
|
|
|
|
|
int imgWidth = m_SrcFrame->width;
|
|
|
|
|
int imgHeight = m_SrcFrame->height;
|
|
|
|
|
|
|
|
|
|
// <20><>ʾͼ<CABE><CDBC>
|
|
|
|
|
IplImage* fitSizeImg = NULL;
|
|
|
|
|
|
|
|
|
|
// <20><>ʾͼ<CABE><CDBC><EFBFBD>ߴ<EFBFBD>
|
|
|
|
|
int fitSizeImgWidth = 0;
|
|
|
|
|
int fitSizeImgHeight = 0;
|
|
|
|
|
|
|
|
|
|
CRect rect;
|
|
|
|
|
pWnd->GetClientRect(&rect);
|
|
|
|
|
|
|
|
|
|
int PicCtrlWidth = rect.Width();
|
|
|
|
|
int PicCtrlHeight = rect.Height();
|
|
|
|
|
|
|
|
|
|
// ͼ<><CDBC><EFBFBD>ߴ<EFBFBD>С<EFBFBD>ڴ<EFBFBD><DAB4>ڳߴ<DAB3>
|
|
|
|
|
if ((imgWidth <= PicCtrlWidth) && (imgHeight <= PicCtrlHeight))
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
|
|
|
|
double Ratio = 1.0;
|
|
|
|
|
double Ratio_Width = static_cast<double>(PicCtrlWidth) / static_cast<double>(imgWidth);
|
|
|
|
|
double Ratio_Height = static_cast<double>(PicCtrlHeight) / static_cast<double>(imgHeight);
|
|
|
|
|
|
|
|
|
|
Ratio = (Ratio_Width < Ratio_Height) ? Ratio_Width : Ratio_Height; // Ratio <20><><EFBFBD><EFBFBD> 1
|
|
|
|
|
|
|
|
|
|
// <20><>ʾͼ<CABE><CDBC><EFBFBD>ߴ<EFBFBD>
|
|
|
|
|
fitSizeImgWidth = static_cast<int>(imgWidth * Ratio + 0.5);
|
|
|
|
|
fitSizeImgHeight = static_cast<int>(imgHeight * Ratio + 0.5);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// ѹ<><D1B9>ͼ<EFBFBD><CDBC>
|
|
|
|
|
double Ratio = 1.0;
|
|
|
|
|
double Ratio_Img = static_cast<double>(imgWidth) / static_cast<double>(imgHeight);
|
|
|
|
|
double Ratio_ClientRect = static_cast<double>(PicCtrlWidth) / static_cast<double>(PicCtrlHeight);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>
|
|
|
|
|
if ( Ratio_Img > Ratio_ClientRect )
|
|
|
|
|
{
|
|
|
|
|
Ratio = static_cast<double>(PicCtrlWidth) / static_cast<double>(imgWidth); // Ratio С<><D0A1> 1
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Ratio = static_cast<double>(PicCtrlHeight) / static_cast<double>(imgHeight); // Ratio С<><D0A1> 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><>ʾͼ<CABE><CDBC><EFBFBD>ߴ<EFBFBD>
|
|
|
|
|
fitSizeImgWidth = static_cast<int>(imgWidth * Ratio + 0.5);
|
|
|
|
|
fitSizeImgHeight = static_cast<int>(imgHeight * Ratio + 0.5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ͳߴ<CDB3><DFB4>жϣ<D0B6>С<EFBFBD><D0A1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱֱ<CAB1>ӷ<EFBFBD><D3B7><EFBFBD>
|
|
|
|
|
if(min(fitSizeImgWidth, fitSizeImgHeight) <= 1)
|
|
|
|
|
{
|
|
|
|
|
// <20>ͷ<EFBFBD>
|
|
|
|
|
ReleaseDC(pDC);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>fitSizeImg
|
|
|
|
|
fitSizeImg = cvCreateImage(cvSize(fitSizeImgWidth, fitSizeImgHeight), m_SrcFrame->depth, m_SrcFrame->nChannels);
|
|
|
|
|
|
|
|
|
|
if (fitSizeImg == NULL)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20>ı<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ߴ<EFBFBD>
|
|
|
|
|
cvResize(m_SrcFrame, fitSizeImg);
|
|
|
|
|
|
|
|
|
|
// Ϊʹ<CEAA><CAB9>ʾ<EFBFBD><CABE><EFBFBD>治<EFBFBD><E6B2BB>˸ <20><><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD> <20>߽<EFBFBD><DFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
IplImage* fillblackImg = NULL;
|
|
|
|
|
fillblackImg = cvCreateImage(cvSize(PicCtrlWidth, PicCtrlHeight), fitSizeImg->depth, fitSizeImg->nChannels);
|
|
|
|
|
|
|
|
|
|
if (fillblackImg != NULL)
|
|
|
|
|
{
|
|
|
|
|
cvZero(fillblackImg); // <20><><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// <20>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>ź<EFBFBD>ͼ<EFBFBD><CDBC>
|
|
|
|
|
cvReleaseImage(&fitSizeImg);
|
|
|
|
|
fitSizeImg = NULL;
|
|
|
|
|
|
|
|
|
|
// <20>ͷ<EFBFBD>pdc
|
|
|
|
|
ReleaseDC(pDC);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><>ʼ<EFBFBD><CABC>
|
|
|
|
|
CPoint LeftUp;
|
|
|
|
|
LeftUp.x = static_cast<int>((PicCtrlWidth - fitSizeImgWidth)/2);
|
|
|
|
|
LeftUp.y = static_cast<int>((PicCtrlHeight - fitSizeImgHeight)/2);
|
|
|
|
|
|
|
|
|
|
cvSetImageROI(fillblackImg, cvRect(static_cast<int>(LeftUp.x), static_cast<int>(LeftUp.y), fitSizeImgWidth, fitSizeImgHeight));
|
|
|
|
|
cvAdd(fillblackImg, fitSizeImg, fillblackImg);
|
|
|
|
|
cvResetImageROI( fillblackImg );
|
|
|
|
|
|
|
|
|
|
// <20><>ͼ
|
|
|
|
|
CvvImage img;
|
|
|
|
|
img.CopyOf(fillblackImg);
|
|
|
|
|
img.Show(hdc, 0, 0, fillblackImg->width, fillblackImg->height);
|
|
|
|
|
|
|
|
|
|
// <20>ͷ<EFBFBD>fitSizeImg
|
|
|
|
|
cvReleaseImage(&fitSizeImg);
|
|
|
|
|
fitSizeImg = NULL;
|
|
|
|
|
|
|
|
|
|
// <20>ͷ<EFBFBD>fillblackImg
|
|
|
|
|
cvReleaseImage(&fillblackImg);
|
|
|
|
|
fillblackImg = NULL;
|
|
|
|
|
|
|
|
|
|
// <20>ͷ<EFBFBD>
|
|
|
|
|
ReleaseDC(pDC);
|
|
|
|
|
pDC = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><>ǰ<EFBFBD><C7B0>ҳ
|
|
|
|
|
void CFastLookUpDlg::OnBnClickedBtnPrePage()
|
|
|
|
|
{
|
|
|
|
|
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (m_iPage == 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_iPage = 0;
|
|
|
|
|
ShowImgData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ
|
|
|
|
|
void CFastLookUpDlg::OnBnClickedBtnNextPage()
|
|
|
|
|
{
|
|
|
|
|
if (m_iPage == 1)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_iPage = 1;
|
|
|
|
|
ShowImgData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CFastLookUpDlg::OnPaint()
|
|
|
|
|
{
|
|
|
|
|
CPaintDC dc(this); // device context for painting
|
|
|
|
|
// TODO: <20>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// <20><>Ϊ<EFBFBD><CEAA>ͼ<EFBFBD><CDBC>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD> CDialogEx::OnPaint()
|
|
|
|
|
|
|
|
|
|
ShowImgData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOL CFastLookUpDlg::OnInitDialog()
|
|
|
|
|
{
|
|
|
|
|
CDialogEx::OnInitDialog();
|
|
|
|
|
|
|
|
|
|
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC>
|
|
|
|
|
CRect rect;
|
|
|
|
|
GetDlgItem(IDC_STATIC_IMG1)->GetWindowRect(&rect);
|
|
|
|
|
ScreenToClient(&rect);
|
|
|
|
|
m_picCtrlRect[0] = rect;
|
|
|
|
|
|
|
|
|
|
GetDlgItem(IDC_STATIC_IMG2)->GetWindowRect(&rect);
|
|
|
|
|
ScreenToClient(&rect);
|
|
|
|
|
m_picCtrlRect[1] = rect;
|
|
|
|
|
|
|
|
|
|
GetDlgItem(IDC_STATIC_IMG3)->GetWindowRect(&rect);
|
|
|
|
|
ScreenToClient(&rect);
|
|
|
|
|
m_picCtrlRect[2] = rect;
|
|
|
|
|
|
|
|
|
|
GetDlgItem(IDC_STATIC_IMG4)->GetWindowRect(&rect);
|
|
|
|
|
ScreenToClient(&rect);
|
|
|
|
|
m_picCtrlRect[3] = rect;
|
|
|
|
|
|
|
|
|
|
GetDlgItem(IDC_STATIC_IMG5)->GetWindowRect(&rect);
|
|
|
|
|
ScreenToClient(&rect);
|
|
|
|
|
m_picCtrlRect[4] = rect;
|
|
|
|
|
|
|
|
|
|
GetDlgItem(IDC_STATIC_IMG6)->GetWindowRect(&rect);
|
|
|
|
|
ScreenToClient(&rect);
|
|
|
|
|
m_picCtrlRect[5] = rect;
|
|
|
|
|
|
|
|
|
|
GetDlgItem(IDC_STATIC_IMG7)->GetWindowRect(&rect);
|
|
|
|
|
ScreenToClient(&rect);
|
|
|
|
|
m_picCtrlRect[6] = rect;
|
|
|
|
|
|
|
|
|
|
GetDlgItem(IDC_STATIC_IMG8)->GetWindowRect(&rect);
|
|
|
|
|
ScreenToClient(&rect);
|
|
|
|
|
m_picCtrlRect[7] = rect;
|
|
|
|
|
|
|
|
|
|
GetDlgItem(IDC_STATIC_IMG9)->GetWindowRect(&rect);
|
|
|
|
|
ScreenToClient(&rect);
|
|
|
|
|
m_picCtrlRect[8] = rect;
|
|
|
|
|
|
|
|
|
|
m_bFastLookUpLeft.SubclassDlgItem(IDC_BTN_PRE_PAGE, this);
|
|
|
|
|
m_bFastLookUpLeft.SetIcon(IDI_ICON_LEFT);
|
|
|
|
|
m_bFastLookUpLeft.SetTooltipText("<EFBFBD><EFBFBD>һҳ");
|
|
|
|
|
|
|
|
|
|
m_bFastLookUpRight.SubclassDlgItem(IDC_BTN_NEXT_PAGE, this);
|
|
|
|
|
m_bFastLookUpRight.SetIcon(IDI_ICON_RIGHT);
|
|
|
|
|
m_bFastLookUpRight.SetTooltipText("<EFBFBD><EFBFBD>һҳ");
|
|
|
|
|
|
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
|
|
|
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20>ж<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ھ<EFBFBD><DABE>ο<EFBFBD><CEBF><EFBFBD>
|
|
|
|
|
bool CFastLookUpDlg::pointRectTest(CPoint pt, CRect rect)
|
|
|
|
|
{
|
|
|
|
|
if (pt.x >= rect.left && pt.x <= rect.right
|
|
|
|
|
&& pt.y >= rect.top && pt.y <= rect.bottom)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CFastLookUpDlg::OnLButtonDblClk(UINT nFlags, CPoint point)
|
|
|
|
|
{
|
|
|
|
|
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ
|
|
|
|
|
int i = 0;
|
|
|
|
|
if (true == pointRectTest(point, m_picCtrlRect[0]))
|
|
|
|
|
{
|
|
|
|
|
i = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (true == pointRectTest(point, m_picCtrlRect[1]))
|
|
|
|
|
{
|
|
|
|
|
i = 2;
|
|
|
|
|
}
|
|
|
|
|
else if (true == pointRectTest(point, m_picCtrlRect[2]))
|
|
|
|
|
{
|
|
|
|
|
i = 3;
|
|
|
|
|
}
|
|
|
|
|
else if (true == pointRectTest(point, m_picCtrlRect[3]))
|
|
|
|
|
{
|
|
|
|
|
i = 4;
|
|
|
|
|
}
|
|
|
|
|
else if (true == pointRectTest(point, m_picCtrlRect[4]))
|
|
|
|
|
{
|
|
|
|
|
i = 5;
|
|
|
|
|
}
|
|
|
|
|
else if (true == pointRectTest(point, m_picCtrlRect[5]))
|
|
|
|
|
{
|
|
|
|
|
i = 6;
|
|
|
|
|
}
|
|
|
|
|
else if (true == pointRectTest(point, m_picCtrlRect[6]))
|
|
|
|
|
{
|
|
|
|
|
i = 7;
|
|
|
|
|
}
|
|
|
|
|
else if (true == pointRectTest(point, m_picCtrlRect[7]))
|
|
|
|
|
{
|
|
|
|
|
i = 8;
|
|
|
|
|
}
|
|
|
|
|
else if (true == pointRectTest(point, m_picCtrlRect[8]))
|
|
|
|
|
{
|
|
|
|
|
i = 9;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
i = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (i >= 1 && i <= 9 && m_iPage == 1)
|
|
|
|
|
{
|
|
|
|
|
i = i + 9;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_ptrParent != nullptr)
|
|
|
|
|
{
|
|
|
|
|
CImgShowDlg *pt = nullptr;
|
|
|
|
|
pt = reinterpret_cast<CImgShowDlg*>(m_ptrParent);
|
|
|
|
|
if (pt != nullptr)
|
|
|
|
|
{
|
|
|
|
|
pt->ShowSelectedImgInMem(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CDialogEx::OnLButtonDblClk(nFlags, point);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void CFastLookUpDlg::ClearMemory()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> <20><>Ҫ<EFBFBD>ͷŸ<CDB7>ͼ<EFBFBD><CDBC>
|
|
|
|
|
if (m_SrcFrame != NULL)
|
|
|
|
|
{
|
|
|
|
|
cvReleaseImage(&m_SrcFrame);
|
|
|
|
|
m_SrcFrame = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20>鱨<EFBFBD><E9B1A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if(m_ImgStruDeque.size() > 0)
|
|
|
|
|
{
|
|
|
|
|
for (size_t i = 0; i < m_ImgStruDeque.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
SAFE_DELETE_ARRAY(m_ImgStruDeque[i].buff);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_ImgStruDeque.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
|
|
|
|
|
if (this->GetSafeHwnd() != NULL)
|
|
|
|
|
{
|
|
|
|
|
Invalidate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(cv::Exception &e)
|
|
|
|
|
{
|
|
|
|
|
e.msg;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
catch(...)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20>Ƿ<EFBFBD><C7B7>м<EFBFBD><D0BC><EFBFBD>ͼ<EFBFBD><CDBC>
|
|
|
|
|
bool CFastLookUpDlg::isEmpty()
|
|
|
|
|
{
|
|
|
|
|
return m_ImgStruDeque.empty();
|
|
|
|
|
}
|