取图View.cpp
资源名称:TankWar.rar [点击查看]
上传用户:jindun001
上传日期:2021-02-02
资源大小:13780k
文件大小:4k
源码类别:
射击游戏
开发平台:
Visual C++
- // 取图View.cpp : implementation of the CMyView class
- //
- #include "stdafx.h"
- #include "取图.h"
- #include "取图Doc.h"
- #include "取图View.h"
- #pragma comment(lib,"ReadPicture_dll.lib")
- extern "C" _declspec(dllexport)void ReadFilePicture(int *arr ,int point ,int Wide,int High);
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- int a[300][300];
- /////////////////////////////////////////////////////////////////////////////
- // CMyView
- IMPLEMENT_DYNCREATE(CMyView, CView)
- BEGIN_MESSAGE_MAP(CMyView, CView)
- //{{AFX_MSG_MAP(CMyView)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- // DO NOT EDIT what you see in these blocks of generated code!
- //}}AFX_MSG_MAP
- // Standard printing commands
- ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMyView construction/destruction
- CMyView::CMyView()
- {
- // TODO: add construction code here
- }
- CMyView::~CMyView()
- {
- }
- BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMyView drawing
- void CMyView::OnDraw(CDC* pDC)
- {
- CMyDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // TODO: add draw code for native data here
- CBitmap bm;
- bm.LoadBitmap(IDB_BITMAP2);
- CDC dcMem;
- dcMem.CreateCompatibleDC(pDC);
- CBitmap*pOldbmp=dcMem.SelectObject(&bm);
- pDC->BitBlt(0,0,112,112,&dcMem,0,0,SRCCOPY);
- dcMem.SelectObject(pOldbmp);
- CDC*pDC1=GetDC();
- FILE *fp;
- fp=fopen("player.dat","wb");
- if(!fp)
- {
- MessageBox("失败");
- }
- for(int i=0;i<112;i++)
- for(int j=0;j<112;j++)
- {
- a[i][j]=pDC1->GetPixel(i,j);
- fwrite(&a[i][j],4,1,fp);
- // flag=1;
- }
- fclose(fp);
- ReleaseDC(pDC1);
- // CDC*pDC=GetDC();
- /* FILE *fp;
- fp=fopen("emery.dat","rb");
- if(!fp)
- {
- MessageBox("失败");
- }
- for(int i=0;i<112;i++)
- for(int j=0;j<112;j++)
- {
- fread(&a[i][j],4,1,fp);
- if(a[i][j]!=RGB(4,4,4))
- pDC->SetPixel(i,j,a[i][j]);
- }
- for(i=0;i<28;i++)
- for(int j=0;j<28;j++)
- {
- if(a[i][j]!=RGB(4,4,4))
- pDC->SetPixel(300+i,200+j,a[i][j]);
- }
- fclose(fp);*/
- // int b[112*112];
- /* ReadFilePicture(a[0],1,112,112);
- for(int i=0;i<112;i++)
- for(int j=0;j<112;j++)
- {
- if(a[i][j]!=RGB(0,0,0))
- pDC->SetPixel(i,j,a[i][j]);
- }*/
- /* int Wide=112,High=112;
- //int b[112*112];
- FILE *fp;
- fp=fopen("emery.dat","rb");
- if(!fp)
- {
- return;
- }
- for(int i=0;i<Wide;i++)
- for(int j=0;j<High;j++)
- fread(&a[i*112+j],4,1,fp);
- fclose(fp);
- for( i=0;i<112;i++)
- for(int j=0;j<112;j++)
- {
- if(a[i][j]!=RGB(4,4,4))
- pDC->SetPixel(i,j,a[i][j]);
- }*/
- //void PutPicture(int flag,int countx,int county,CDC* pDC)
- //{
- /* int flag=1;int countx=1;int county=2;int sizetangke=28;
- if(1==flag)
- {
- for(int i=sizetangke*(countx-1);i<sizetangke*countx;i++)
- for(int j=sizetangke*(county-1);j<sizetangke*county;j++)
- {
- if(a[i][j]!=RGB(0,0,0))
- pDC->SetPixel(300+i,j,a[i][j]);
- }
- }
- //}
- */
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMyView printing
- BOOL CMyView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CMyView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void CMyView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMyView diagnostics
- #ifdef _DEBUG
- void CMyView::AssertValid() const
- {
- CView::AssertValid();
- }
- void CMyView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- CMyDoc* CMyView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc)));
- return (CMyDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMyView message handlers