// NEWONEView.cpp : implementation of the CNEWONEView class
//
#include "stdafx.h"
#include "NEWONE.h"
#include "NEWONEDoc.h"
#include "NEWONEView.h"
#include "SETTINGDIAL.H"
#include "PHOTODIAL.H"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CNEWONEView
IMPLEMENT_DYNCREATE(CNEWONEView, CView)
BEGIN_MESSAGE_MAP(CNEWONEView, CView)
//{{AFX_MSG_MAP(CNEWONEView)
ON_COMMAND(ID_MENUSAVEO, OnMenusaveo)
ON_COMMAND(ID_MENUSETTING, OnMenusetting)
ON_COMMAND(ID_MENUSAVE, OnMenusave)
ON_COMMAND(ID_MENUOPEN, OnMenuopen)
ON_COMMAND(ID_MENUHELP, OnMenuhelp)
ON_COMMAND(ID_MENUENCODE, OnMenuencode)
ON_COMMAND(ID_MENUDECODE, OnMenudecode)
ON_WM_LBUTTONDOWN()
ON_WM_CREATE()
ON_WM_DROPFILES()
ON_COMMAND(ID_MENUPHOTO, OnMenuphoto)
ON_UPDATE_COMMAND_UI(ID_MENUPHOTO, OnUpdateMenuphoto)
ON_UPDATE_COMMAND_UI(ID_MENUDESFILE, OnUpdateMenudesfile)
ON_COMMAND(ID_MENUDESFILE, OnMenudesfile)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNEWONEView construction/destruction
CNEWONEView::CNEWONEView()
{
// TODO: add construction code here
}
CNEWONEView::~CNEWONEView()
{
}
BOOL CNEWONEView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CNEWONEView drawing
void CNEWONEView::OnDraw(CDC* pDC)
{ CNEWONEDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
HBITMAP bitmap;
HBITMAP oldbitmap;
CDC memdc;CRect rect;
if(FileName=="") bitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP1),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION);
else
bitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),FileName,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
memdc.CreateCompatibleDC(pDC);
GetClientRect(rect);
oldbitmap=(HBITMAP)memdc.SelectObject(bitmap);
pDC->BitBlt(0,0,rect.Width(),rect.Height(),&memdc,0,0,SRCCOPY);
memdc.SelectObject(oldbitmap);
}
/////////////////////////////////////////////////////////////////////////////
// CNEWONEView diagnostics
#ifdef _DEBUG
void CNEWONEView::AssertValid() const
{
CView::AssertValid();
}
void CNEWONEView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CNEWONEDoc* CNEWONEView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CNEWONEDoc)));
return (CNEWONEDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CNEWONEView message handlers
void CNEWONEView::OnMenusaveo()
{
// TODO: Add your command handler code here
CFile file;
if (lpBitmap==0) return;
CFileDialog dlg(false, 0, 0, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "*.bmp|*.bmp|\0");
if (dlg.DoModal()==IDOK)
{
FileName=dlg.GetPathName();
if(!(FileName.Find(".bmp")+1)) FileName+=".bmp";
if (!file.Open((LPCTSTR)FileName,CFile::modeWrite|CFile::modeCreate)) return;
int nLen=nByteWidth*nHeight;
BYTE *pMem=new BYTE[nLen+sizeof(BITMAPINFOHEADER)];
BITMAPINFOHEADER *bmi=(BITMAPINFOHEADER *)pMem;
bmi->biSize=sizeof(BITMAPINFOHEADER);
bmi->biWidth=nWidth;
bmi->biHeight=nHeight;
bmi->biPlanes=1;
bmi->biBitCount=24;
bmi->biCompression=BI_RGB;
bmi->biSizeImage=0;
bmi->biXPelsPerMeter=0;
bmi->biYPelsPerMeter=0;
bmi->biClrUsed=0;
bmi->biClrImportant=0;
BITMAPFILEHEADER bmh;
bmh.bfType='B'+'M'*256;
bmh.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+nLen;
bmh.bfReserved1=(WORD)(FileLen>>16);
bmh.bfReserved2=(WORD)(FileLen);
bmh.bfOffBits=54;
memcpy(pMem+sizeof(BITMAPINFOHEADER),lpBits,nLen);
file.Write(&bmh,sizeof(BITMAPFILEHEADER));
file.Write(pMem,nLen+sizeof(BITMAPINFOHEADER));
file.Close();
}
}
void CNEWONEView::OnMenusetting()
{
SETTINGDIAL dlg(Front,nLen,FileLen);
dlg.DoModal();
}
void CNEWONEView::OnMenusave()
{
CFile file;
if (lpBitmap==0) return;
if(!file.Open((LPCTSTR)FileName,CFile::modeWrite)) return;
int nLen=nByteWidth*nHeight;
BYTE *pMem=new BYTE[nLen+sizeof(BITMAPINFOHEADER)];
BITMAPINFOHEADER *bmi=(BITMAPINFOHEADER *)pMem;
bmi->biSize=sizeof(BITMAPINFOHEADER);
bmi->biWidth=nWidth;
bmi->biHeight=nHeight;
bmi->biPlanes=1;
bmi->biBitCount=24;
bmi->biCompression=BI_RGB;
bmi->biSizeImage=0;
bmi->biXPelsPerMeter=0;
bmi->biYPelsPerMeter=0;
bmi->biClrUsed=0;
bmi->biClrImportant=0;
BITMAPFILEHEADER bmh;
bmh.bfType='B'+'M'*256;
bmh.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+nLen;
bmh.bfReserved1=(WORD)(FileLen>>16);
bmh.bfReserved2=(WORD)(FileLen);
bmh.bfOffBits=54;
memcpy(pMem+sizeof(BITMAPINFOHEADER),lpBits,nLen);
file.Write(&bmh,sizeof(BITMAPFILEHEADER));
file.Write(pMem,nLen+sizeof(BITMAPINFOHEADER));
file.Close();
}
void CNEWONEView::OnMenuopen()
{
CFile File=0;
CFileDialog dlg(TRUE, 0, 0, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "*.bmp|*.bmp|\0");
if (dlg.DoModal()==IDOK)
{
if (!File.Open((LPCTSTR)dlg.GetPathName(),CFile::modeRead)) return;
FileName=dlg.GetPathName();
CuttheName();
nLen=File.GetLength();
lpBitmap=new unsigned char[nLen];
File.Read(lpBitmap,nLen);
File.Close();
LoadBitmap();
menuphoto=true;
CDC *pDC;
pDC=GetDC();
CRect rect;
GetClientRect(&rect);
InvalidateRect(&rect);
OnDraw(pDC);
}
}
void CNEWONEView::OnMenuhelp()
{
DWORD nBufferLength=300;
char lpBuffer[100]="";
GetCurrentDirectory (nBufferLength,lpBuffer);
CString pHelpPath=lpBuffer;
pHelpPath+="\\readme.chm";
ShellExecute(NULL, "open",pHelpPath, NULL, NULL, SW_SHOWNORMAL);
}
void CNEWONEView::OnMenuencode()
{
int p;
CString SorFilName;
if(Front=="") {AfxMessageBox("请加载载体图片!详情请看帮助");return;}
CFile SourceFile=0;
CFileDialog dlg(TRUE, 0, 0, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT);
if (dlg.DoModal()==IDOK)
{
int Position;
SorFilName=dlg.GetPathName();
Position=SorFilName.Find(".");
CString tail;
tail=SorFilName.Mid(Position+1);
const char *a;
a=tail;
unsigned int len;
len=tail.GetLength();
DWORD SorFilLen;
char *buf;
SourceFile.Open(SorFilName,CFile::modeRead);
SorFilLen=SourceFile.GetLength();
if(SorFilLen>((DWORD)nLen-54-3-18)/3) {AfxMessageBox("文件太大,请换更大的载体图片!");return;}
int ret;
if(jzflag) {
ret=AfxMessageBox("文件已经加载过了!是否覆盖?",MB_YESNO);
if(ret==IDNO) return;}
FileLen=SorFilLen;
buf=new char[SorFilLen];
SourceFile.Read(buf,SorFilLen);
SourceFile.Close();
char *str;
str=buf;
p=0;
lpBits[p]=(lpBits[p]&(0xf0))|((char)(tail.GetLength())&(0x0f));
lpBits[p+2]=(lpBits[p+2]&(0xf0))|(((char)(tail.GetLength())&(0xf0))>>4);
p+=3;
for(DWORD i=0;i<len;i++)
{
lpBits[p]=(lpBits[p]&(0xf0))|((a[i])&(0x0f));
lpBits[p+2]=(lpBits[p+2]&(0xf0))|(((a[i])&(0xf0))>>4);
p+=3;
}
for(i=0;i<FileLen;i++)
{
lpBits[p]=(lpBits[p]&(0xf0))|((*str)&(0x0f));
lpBits[p+2]=(lpBits[p+2]&(0xf0))|(((*str)&(0xf0))>>4);
p+=3;
str++;
}
delete []buf;
}
}
void CNEWONEView::OnMenudecode()
{
CFile DesFile=0;
CString DesFilName;
CString ext;
ext="";
int p;
p=0;
unsigned int len;
len=int((lpBits[p]&(0x0f))|((lpBits[p+2]&(0x0f))<<4));
p+=3;
for(DWORD i=0;i<len;i++)
{ext=ext+char((lpBits[p]&(0x0f))|((lpBits[p+2]&(0x0f))<<4));
p+=3;
}
CString filter;
filter="*."+ext+"|*."+ext+"|\0";
CFileDialog dlg(FALSE, 0, 0, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,filter);
if (dlg.DoModal()==IDOK)
{ ext="."+ext;
商业编程-源码-图象载码程序源代码.zip
版权申诉
44 浏览量
2022-06-23
17:46:02
上传
评论
收藏 78KB ZIP 举报
programxh
- 粉丝: 17
- 资源: 1万+
最新资源
- MyBatis动态SQL是一种强大的特性,它允许我们在SQL语句中根据条件动态地添加或删除某些部分,从而实现更加灵活和高效的数据
- MyBatis动态SQL是一种强大的特性,它允许我们在SQL语句中根据条件动态地添加或删除某些部分,从而实现更加灵活和高效的数据
- 【ERP标准流程-标准流程-进货管理】(DOC 17页).doc
- MyBatis动态SQL是一种强大的特性,它允许我们在SQL语句中根据条件动态地添加或删除某些部分,从而实现更加灵活和高效的数据
- MyBatis动态SQL是一种强大的特性,它允许我们在SQL语句中根据条件动态地添加或删除某些部分,从而实现更加灵活和高效的数据
- Java爬虫项目【项目开发计划】(共12页).docx
- 11111111111
- MyBatis动态SQL是一种强大的特性,它允许我们在SQL语句中根据条件动态地添加或删除某些部分,从而实现更加灵活和高效的数据
- MyBatis动态SQL是一种强大的特性,它允许我们在SQL语句中根据条件动态地添加或删除某些部分,从而实现更加灵活和高效的数据
- MyBatis动态SQL是一种强大的特性,它允许我们在SQL语句中根据条件动态地添加或删除某些部分,从而实现更加灵活和高效的数据
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈