본문 바로가기

VC수업 Report로 나왔던 간단한 이미지 저장 루틴입니다. 참고하세요.
배워서 남주자 !!!


class CTestView : public CScrollView { protected: // create from serialization only CTestView(); DECLARE_DYNCREATE(CTestView) // Attributes public: CTestDoc* GetDocument(); // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CTestView) public: virtual void OnDraw(CDC* pDC); // overridden to draw this view virtual BOOL PreCreateWindow(CREATESTRUCT& cs); protected: virtual void OnInitialUpdate(); // called first time after construct virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); //}}AFX_VIRTUAL // Implementation public: virtual ~CTestView(); unsigned char m_ViewImg[250][250]; #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // Generated message map functions protected: //{{AFX_MSG(CTestView) afx_msg void OnLButtonDown(UINT nFlags, CPoint point); //}}AFX_MSG DECLARE_MESSAGE_MAP() private: int m_penColor; int m_nWidth; BOOL m_bPressed; CPoint m_ptOld; }; void CTestView::OnDraw(CDC* pDC) { CTestDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here for(int y=0;y<250;y++) { for(int x=0;x<250;x++){ pDC->SetPixel(x,y,RGB(m_ViewImg[y][x],m_ViewImg[y][x],m_ViewImg[y][x])); } } } void CTestView::OnInitialUpdate() { CScrollView::OnInitialUpdate(); CSize sizeTotal; // TODO: calculate the total size of this view CTestDoc* pDoc=GetDocument(); for(int x=0;x<250;x++){ for(int y=0;y<250;y++){ m_ViewImg[x][y]=pDoc->m_OpenImg[x][y]; pDoc->m_WriteImg[x][y] = m_ViewImg[x][y]; } } sizeTotal.cx = sizeTotal.cy = 100; SetScrollSizes(MM_TEXT, sizeTotal); } CTestView::CTestView() { // TODO: add construction code here m_ptOld=CPoint(0,0); m_bPressed=FALSE; m_nWidth=3; m_penColor=RGB(0,0,255); } class CTestDoc : public CDocument { protected: // create from serialization only CTestDoc(); DECLARE_DYNCREATE(CTestDoc) // Attributes public: // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CTestDoc) public: virtual BOOL OnNewDocument(); virtual void Serialize(CArchive& ar); virtual BOOL OnOpenDocument(LPCTSTR lpszPathName); virtual BOOL OnSaveDocument(LPCTSTR lpszPathName); //}}AFX_VIRTUAL // Implementation public: virtual ~CTestDoc(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif unsigned char m_OpenImg[250][250]; unsigned char m_WriteImg[250][250]; protected: // Generated message map functions protected: //{{AFX_MSG(CTestDoc) // NOTE - the ClassWizard will add and remove member functions here. // DO NOT EDIT what you see in these blocks of generated code ! //}}AFX_MSG DECLARE_MESSAGE_MAP() private: }; void CTestDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: add storing code here ar.Write(m_WriteImg,250*250); } else { // TODO: add loading code here CFile*fp=ar.GetFile(); if(fp->GetLength()!=250*250) { AfxMessageBox("250*250 이미지가 아닙니다"); return; } ar.Read(m_OpenImg,fp->GetLength()); } }




번호 제목 날짜 조회 수
HOT [TIP] PYTHON 에서 "UnicodeDecodeError: 'cp949' codec can't decode byte 0xe2 in position 6987: illegal multibyte sequence" 오류 날때... [52] 2016.02.20 266446
HOT [펌] ARM GCC Inline Assembler Cookbook 2006.08.18 57976
HOT [TIP] R에서 페이스북 페이지 정보 크롤링 하기 [6] 2017.02.11 39898
» [VC소스]이미지 파일 저장 루틴(기초) 1999.11.18 712
49 [VC소스]VIEW에 낙서하기 1999.11.12 952
48 [C++소스]가중치구하기? 1999.10.28 1768
47 [VC소스]윈도우 모양을 마음데로... 1999.10.26 732
46 알고리즘 구현...(1) 1999.06.05 523
45 가상키보드 후킹 포커스 문제... [1] 2010.12.10 13009
44 소스코드에 대한 추가질문입니다^^ [1] 2009.05.26 518
43 마무리 질문일듯합니다^^^^^^ [1] 2009.05.14 1614
42 밑에 소스에 대한 추가질문입니다 ^^ [1] 2009.05.13 719
41 홈페이지 주인님 소스에 대한 질문입니다 [1] 2009.05.12 871
40 Gunshadow가 관련된 질문 입니다. [1] 2007.12.17 467
39 Gunshadow.sys 파일의 바이러스 진단 여부에 대한 문의입니다. [5] 2007.12.11 489
38 Gunshadow.sys,dll파일 삭제에 관해서, [1] 2007.12.01 868
37 레지스트리후킹 [1] 2006.11.17 704
36 그래도 신호강도를 못 받고 있습니다.ㅠ0ㅠ [1] 2006.06.27 596
35 무선랜카드에서 연결속도 및 신호강도 받아오는 방법이 궁금합니다. [1] 2006.06.26 1120
34 CRC - 16 소스 수정할려고 하는데 어떻게 해야할지.. 질문드립니다. [1] 2006.06.23 1120
33 Extern을 이용하여 모듈화 할때 문제점 질문드립니다!!! [1] 2006.06.23 673
32 visual C를 이용해서 미디어 플레이어 짜는법좀 [1] 2006.04.27 569
31 시리얼통신관련 질문..(응답속도에 관해..) [1] 2006.04.03 1133