www.pudn.com > XRayImg.rar > DibDispStatic.cpp
// DibDispStatic.cpp : implementation file
//
#include "stdafx.h"
#include "XRayImg.h"
#include "DibDispStatic.h"
#include "XRayImgDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDibDispStatic
CDibDispStatic::CDibDispStatic()
{
}
CDibDispStatic::~CDibDispStatic()
{
}
BEGIN_MESSAGE_MAP(CDibDispStatic, CStatic)
//{{AFX_MSG_MAP(CDibDispStatic)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDibDispStatic message handlers
//***************************************************************
//函数: 初始化程序
// 1) 颜色复位
// 2)
//
//说明:
//***************************************************************
void CDibDispStatic::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
CRect rcThis;
this->GetClientRect(rcThis);
m_dib.SetUndoSize(5);
m_dib=g_theApp.GetDocDibSource();
m_dib.ResizeImageSize( rcThis.Width(),rcThis.Height(),FALSE );
this->ResetColor();
CStatic::PreSubclassWindow();
}
void CDibDispStatic::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect rcThis;
this->GetClientRect(rcThis);
m_dib.Draw(dc, &rcThis);
// Do not call CStatic::OnPaint() for painting messages
}
//***************************************************************
//函数: 颜色复位
// 1) 初始化图像
// 2) 显示图像
//
//说明:
//***************************************************************
BOOL CDibDispStatic::ResetColor()
{
CWaitCursor wait;
while ( m_dib.UndoAvailable() )
{
m_dib.Undo();
}
if( GetSafeHwnd()) Invalidate();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
//***************************************************************
//函数: 调整亮度等三项
// 1) 得到DIB数据
// 2) 调整显示
//
//说明:
//***************************************************************
BOOL CDibDispStatic::AdjustBCG(int iBright,int iContrast,float iGamma)
{
CWaitCursor wait;
//使用最原始的数据作为修改基础
ResetColor();
if( ! m_dib.AdjustBrightness(iBright) )
return FALSE;
if( !m_dib.AdjustContrast(iContrast) )
return FALSE;
if( !m_dib.AdjustGammaCorrection(iGamma) )
return FALSE;
this->Invalidate();
return TRUE;
}
//***************************************************************
//函数: 调整HSL
// 1) 得到DIB数据
// 2) 调整数据
//
//说明:
//***************************************************************
BOOL CDibDispStatic::AdjustHSL(int perH, int perS, int perL)
{
CWaitCursor wait;
//使用最原始的数据作为修改基础
ResetColor();
if( m_dib.AdjustHSL(perH,perS,perL) )
{
this->Invalidate();
return TRUE;
}
return FALSE;
}
//***************************************************************
//函数: 调整RED GREEN BLUE
// 1) 得到DIB数据
// 2) 调整数据
//
//说明:
//***************************************************************
BOOL CDibDispStatic::AdjustRGB(int iRed,int iGreen,int iBlue)
{
CWaitCursor wait;
//使用最原始的数据作为修改基础
ResetColor();
if( ! m_dib.AdjustRed(iRed) )
return FALSE;
if( ! m_dib.AdjustGreen(iGreen) )
return FALSE;
if( ! m_dib.AdjustBlue(iBlue) )
return FALSE;
this->Invalidate();
return TRUE;
}
//***************************************************************
//函数: highlight midtone shadow
// 1) 得到DIB数据
// 2) 调整数据
//
//说明:
//***************************************************************
BOOL CDibDispStatic::AdjustHMS(int iLight,int iMidtone,int iShadow)
{
CWaitCursor wait;
//使用最原始的数据作为修改基础
ResetColor();
if( !m_dib.AdjustHighLight(iLight) )
return FALSE;
if( !m_dib.AdjustMidtone(iMidtone) )
return FALSE;
if( !m_dib.AdjustShadow(iShadow) )
return FALSE;
this->Invalidate();
return TRUE;
}