seqprocessdlgdisplay.cpp
来自「在人脸检测的基础之上,对嘴部的运动表情进行分析,进行语音模拟.」· C++ 代码 · 共 183 行
CPP
183 行
// SeqProcessDlgDisplay.cpp : implementation file
//
#include "stdafx.h"
#include "SeqProcess.h"
#include "SeqProcessDlg.h"
#include "FnMath.h"
#include "Matrix.h"
#include "FnMatrix.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// Create a math functions object
static FnMath fMath;
////////////////////////////////////////////////////////////////////////////////
void CSeqProcessDlg::InitializeWindowDisplay()
{
// Window title text
m_windowText = _T("Segmentation of Video Sequences");
SetWindowText(m_windowText);
// Set parent window size to default minimum
SetWindowPos(NULL, NULL, NULL, MINWINDOWWIDTH, MINWINDOWHEIGHT, SWP_NOMOVE);
// Make sure the default size setting is successful
CRect rectW; // Parent window (includes the client window)
GetWindowRect(&rectW);
int rectWwidth;
int rectWheight;
rectWwidth = (rectW.right - rectW.left);
rectWheight = (rectW.bottom - rectW.top);
ASSERT( rectWwidth == MINWINDOWWIDTH && rectWheight == MINWINDOWHEIGHT);
// Set the origin (upper-left corner) of the image display
xPosWindow = XWINDOWPOS;
yPosWindow = YWINDOWPOS;
// Make sure client (display) area does not have zero size
CRect rectC; // Client (display) window
GetClientRect(&rectC);
ASSERT( rectC.right > xPosWindow && rectC.bottom > yPosWindow);
// the scaling factor for the images
// 1 if original size
// 2 if double size
scale = 2;
// Compute the size of the required window area
int widthWindow;
int heightWindow;
widthWindow = xPosWindow + scale * m_width; + 20;
heightWindow = yPosWindow + scale * m_height; + 20 ;
//Find the amount the client area (hence the parent window area)
//must be increased to cover the image
int wdiff;
int hdiff;
wdiff = widthWindow - rectC.right;
hdiff = heightWindow - rectC.bottom;
//Increase parent window size to cover the required display area
rectWwidth += (int) fMath.Max(0, wdiff);
rectWheight += (int) fMath.Max(0, hdiff);
SetWindowPos(NULL, NULL, NULL, rectWwidth, rectWheight, SWP_NOMOVE);
CClientDC dc(this);
dc.FillSolidRect( xPosWindow, yPosWindow, scale*m_width, scale*m_height, RGB(127, 127, 127));
}
///////////////////////////////////////////////////////////////////////////
void CSeqProcessDlg::OnOK()
{
UpdateData(TRUE);
if(isEditCurrentFrameNumber)
{
if( m_currentframe < (int) m_fromframe)
{
m_currentframe = m_fromframe;
UpdateData(FALSE);
}
else if( m_currentframe > (int) m_toframe)
{
m_currentframe = m_toframe;
UpdateData(FALSE);
}
currentFrame = m_currentframe - dlgLoadSequence.m_from;
DrawCurrentImage();
m_sliderframe.SetPos( m_currentframe);
isEditCurrentFrameNumber = FALSE;
}
if(isEditFromFrameNumber)
{
if( m_fromframe < (int) dlgLoadSequence.m_from)
{
m_fromframe = dlgLoadSequence.m_from;
}
else if( m_fromframe > m_toframe)
{
m_fromframe = m_toframe;
}
if( m_currentframe < m_fromframe)
{
m_currentframe = m_fromframe;
}
currentFrame = m_currentframe - dlgLoadSequence.m_from;
UpdateData(FALSE);
DrawCurrentImage();
m_sliderframe.SetRange( m_fromframe, m_toframe, TRUE);
m_sliderframe.SetPos( m_currentframe);
isEditFromFrameNumber = FALSE;
}
if(isEditToFrameNumber)
{
if( m_toframe > (int) dlgLoadSequence.m_to)
{
m_toframe = dlgLoadSequence.m_to;
}
else if( m_toframe < m_fromframe)
{
m_toframe = m_fromframe;
}
if( m_currentframe > m_toframe)
{
m_currentframe = m_toframe;
}
currentFrame = m_currentframe - dlgLoadSequence.m_from;
UpdateData(FALSE);
DrawCurrentImage();
m_sliderframe.SetRange( m_fromframe, m_toframe, TRUE);
m_sliderframe.SetPos( m_currentframe);
isEditToFrameNumber = FALSE;
}
// overrides base function
}
//------------------------------------------------------------------------------
void CSeqProcessDlg::OnCancel()
{
// overrides base function
}
//------------------------------------------------------------------------------
BOOL CSeqProcessDlg::IsWithinImageDisplay( int x, int y)
{
if( x >= xPosWindow && y >= yPosWindow && x < xPosWindow + scale*m_width
&& y < yPosWindow + scale*m_height)
{
return TRUE;
}
else
{
return FALSE;
}
}
//------------------------------------------------------------------------------
void CSeqProcessDlg::FindImageCoordinates( int x, int y)
{
m_posX = (x - xPosWindow) / scale;
m_posY = (y - yPosWindow) / scale;
//m_posY = (double)(m_height + yPosWindow - 1 - y);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?