📄 exifvwview.cpp
字号:
// ExifVwView.cpp : CExifVwView 类的实现
//
#include "stdafx.h"
#include "ExifVw.h"
#include "ExifVwDoc.h"
#include "ExifVwView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CExifVwView
IMPLEMENT_DYNCREATE(CExifVwView, CScrollView)
BEGIN_MESSAGE_MAP(CExifVwView, CScrollView)
ON_WM_CREATE()
ON_COMMAND(ID_130, On130)
ON_WM_DESTROY()
END_MESSAGE_MAP()
// CExifVwView 构造/销毁
CExifVwView::CExifVwView()
{
// TODO: 在此处添加构造代码
}
CExifVwView::~CExifVwView()
{
}
BOOL CExifVwView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
// 样式
return CScrollView::PreCreateWindow(cs);
}
// CExifVwView 绘制
void CExifVwView::OnDraw(CDC* pDC)
{
CExifVwDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: 在此处为本机数据添加绘制代码
if(!m_PathFile.IsEmpty())
{
BOOL br=m_Img.Draw(pDC->m_hDC,0,0,m_ImgWidth,m_ImgHeight,0,0,m_ImgWidth,m_ImgHeight);
VERIFY(br!=0);
}
}
void CExifVwView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: 计算此视图的合计大小
sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_TEXT, sizeTotal);
}
// CExifVwView 诊断
#ifdef _DEBUG
void CExifVwView::AssertValid() const
{
CScrollView::AssertValid();
}
void CExifVwView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CExifVwDoc* CExifVwView::GetDocument() const // 非调试版本是内联的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CExifVwDoc)));
return (CExifVwDoc*)m_pDocument;
}
#endif //_DEBUG
// CExifVwView 消息处理程序
int CExifVwView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CScrollView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: 在此添加您专用的创建代码
GetCurrentDirectory(MAX_PATH,m_CurrDir);
if(m_CurrDir[lstrlen(m_CurrDir)-1]!='\\') StrCat(m_CurrDir,"\\");
m_ImgWidth=m_ImgHeight=0;
m_PathFile="";
return 0;
}
void CExifVwView::OnDestroy()
{
CScrollView::OnDestroy();
// TODO: 在此添加消息处理程序代码
if(!m_Img.IsNull())
{
m_Img.Detach();
m_Img.Destroy();
}
}
void CExifVwView::On130()
{ //数码照片
// TODO: 在此添加命令处理程序代码
TCHAR filter[]="数码照片 (*.jpg)|*.jpg|所有文件 (*.*)|*.*||";
CFileDialog FileDlg(1,0,0,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,filter,this);
TCHAR CurrDir[MAX_PATH];
CClientDC cdc(this);
INT_PTR ipr;
StrCpy(CurrDir,m_CurrDir);
ipr=FileDlg.DoModal();
if(IDOK==ipr)
{
m_PathFile=FileDlg.GetPathName();
m_Exif.GetPhotoProp(m_hWnd,m_PathFile);
PreparePhoto(m_PathFile);
RedrawWindow();
StrCat(CurrDir,FileDlg.GetFileTitle());
StrCat(CurrDir,".txt");
DisplayProp(CurrDir);
}
}
void CExifVwView::PreparePhoto(CString PathFile)
{
CSize size;
if(!m_Img.IsNull())
{
m_Img.Detach();
m_Img.Destroy();
}
m_Img.Load(PathFile);
m_ImgWidth=m_Img.GetWidth();
m_ImgHeight=m_Img.GetHeight();
size.cx=m_ImgWidth;
size.cy=m_ImgHeight;
SetScrollSizes(MM_TEXT,size);
}
void CExifVwView::DisplayProp(CString file)
{
CString tag[]=
{
"PropertyTagEquipMake",
"PropertyTagEquipModel",
"PropertyTagExifDTOrig",
"PropertyTagDateTime",
"PropertyTagExifExposureTime",
"PropertyTagExifFNumber",
"PropertyTagExifFocalLength",
"PropertyTagExifFlash",
"PropertyTagExifISOSpeed",
"PropertyTagExifLightSource",
"PropertyTagExifExposureProg",
"PropertyTagExifMeteringMode",
"PropertyTagExifShutterSpeed",
"PropertyTagExifBrightness",
"PropertyTagExifExposureBias",
"PropertyTagExifPixXDim",
"PropertyTagExifPixYDim",
"PropertyTagExifSensingMethod",
"PropertyTagExifMakerNote",
"PropertyTagThumbnailData"
};
TCHAR info[80];
ExifInfo ei;
FILE* fp;
BOOL br;
int n,i;
n=sizeof(tag)/sizeof(tag[0]);
fp=fopen(file,"w");
for(i=0;i<n;++i)
{
br=m_Exif.GetNameAndInfoByTag(tag[i],ei);
if(br)
{
sprintf(info,"%s:\t%s\r\n",ei.name,ei.info);
fwrite(info,1,lstrlen(info),fp);
}
}
fclose(fp);
ShellExecute(m_hWnd,"open",file,0,0,SW_SHOWNORMAL);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -