📄 rephoto.cpp
字号:
// RePhoto.cpp : implementation file
//
#include "stdafx.h"
#include "bxt.h"
#include "bxtdlg.h"
#include "RePhoto.h"
#include "recimage.h"
#include "registry.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRePhoto dialog
CRePhoto::CRePhoto(char *iPath, CWnd* pParent /*=NULL*/)
: CDialog(CRePhoto::IDD, pParent)
{
path = _T(iPath);
imgNum=1;
char xfilename[256];
while(imgNum<100)
{
sprintf(xfilename,"%s%d.jpg",path.GetBuffer(200),imgNum);
FILE *fp;
fp=fopen(xfilename,"rb");
if(fp!=NULL)
{
mpp[imgNum]=new CPic;
#ifdef COLORPIC
mpp[imgNum]->loadjpg(xfilename);
#else
mpp[imgNum]->loadjpgGry(xfilename);
#endif
mpp[imgNum]->SetImageID(imgNum);
fclose(fp);
imgNum++;
}
else
{
break;
}
}
imgNum --;
//{{AFX_DATA_INIT(CRePhoto)
m_bri = 0;
//}}AFX_DATA_INIT
}
void CRePhoto::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRePhoto)
DDX_Text(pDX, IDC_EDIT1, m_bri);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRePhoto, CDialog)
//{{AFX_MSG_MAP(CRePhoto)
ON_BN_CLICKED(IDOK, OnOk)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRePhoto message handlers
void CRePhoto::OnOk()
{
for(int i=1;i<=imgNum;i++)
{
mpp[i]->Close();
//delete mpp[i];
}
((CBxtDlg*)AfxGetMainWnd())->rec->SendMessage(WX_STOP,0,0);
CDialog::OnOK();
}
void CRePhoto::OnCancel()
{
//CDialog::OnCancel();
}
void CRePhoto::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
if(imgNum>0)
{
//unsigned char* bbuf=new unsigned char[768*576*2];
//memset(bbuf,0,768*576*2);
mpp[curImg]->SetZoom(&dc,1,990,700);
mpp[curImg]->ZoomBMP(&dc,1,1,990,700,0,0);
//mpp[curImg]->DrawBMP(&dc,10,0,990,700,0);
//mpp[curImg]->savebmp("c:\\xxt000.bmp");
/*for(int i=0;i<576;i++)
for(int j=0;j<768;j++)
{
//bbuf[j*2+i*768*2]=mpp[curImg]->m_buf[j*3+i*mpp[curImg]->m_width*3];
if(i<200)
{
bbuf[j*2+i*768*2]=j%256;
bbuf[j*2+1+i*768*2]=0;
}
}*/
((CBxtDlg*)AfxGetMainWnd())->rec->SendMessage(WX_REPHOTO,MAKEWPARAM(mpp[curImg]->m_height,mpp[curImg]->m_width),(long)(mpp[curImg]->m_buf));
//delete []bbuf;
}
char tts[100];
sprintf(tts,"当前为第 %d 幅图像, 该份病历共 %d 幅图像",curImg,imgNum);
dc.TextOut(420,712,tts,strlen(tts));
// Do not call CDialog::OnPaint() for painting messages
}
void CRePhoto::OnButton2()
{
if(curImg==1)
{
GetDlgItem(IDC_BUTTON1)->EnableWindow(true);
}
if(curImg<imgNum)
{
curImg++;
Invalidate();
}
if(curImg==imgNum)
{
GetDlgItem(IDC_BUTTON2)->EnableWindow(false);
}
}
void CRePhoto::OnButton1()
{
if(curImg==imgNum)
{
GetDlgItem(IDC_BUTTON2)->EnableWindow(true);
}
if(curImg>1)
{
curImg--;
Invalidate();
}
if(curImg==1)
{
GetDlgItem(IDC_BUTTON1)->EnableWindow(false);
}
}
BOOL CRePhoto::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
if(imgNum>0)
curImg=1;
else
{
GetDlgItem(IDC_BUTTON1)->EnableWindow(false);
GetDlgItem(IDC_BUTTON2)->EnableWindow(false);
curImg=0;
}
CRegistry reg;
if(reg.VerifyKey(HKEY_LOCAL_MACHINE,"SOFTWARE\\xiebaodong\\bxt"))
{
reg.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\xiebaodong\\bxt");
reg.Read("RephotoBri",m_bri);
//CString hid;
//int did;
//if (reg.Read("scaner_name",hid)!=0) scaner_name = hid;
//if (reg.Read("scaner_win_title",hid)!=0) scaner_title = hid;
//strcpy(scanwintitle,hid.GetBuffer(10));
reg.Close();
}
else
m_bri=500;
UpdateData(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CRePhoto::OnButton4()
{
UpdateData();
char ttt[100];
sprintf(ttt,"%d",m_bri);
AfxMessageBox(ttt);
((CBxtDlg*)AfxGetMainWnd())->rec->SendMessage(WX_SETREBRI,m_bri,0);
CRegistry reg;
if(reg.VerifyKey(HKEY_LOCAL_MACHINE,"SOFTWARE\\xiebaodong\\bxt"))
{
reg.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\xiebaodong\\bxt");
reg.Write("RephotoBri",m_bri);
//CString hid;
//int did;
//if (reg.Read("scaner_name",hid)!=0) scaner_name = hid;
//if (reg.Read("scaner_win_title",hid)!=0) scaner_title = hid;
//strcpy(scanwintitle,hid.GetBuffer(10));
reg.Close();
}
else
{
reg.CreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\xiebaodong\\bxt");
reg.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\xiebaodong\\bxt");
reg.Write("RephotoBri",m_bri);
reg.Close();
}
Invalidate();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -