-
Notifications
You must be signed in to change notification settings - Fork 2
/
Graydoc.cpp
executable file
·68 lines (57 loc) · 1.45 KB
/
Graydoc.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// GrayDoc.cpp: implementation of the CGrayDoc class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ImageS.h"
#include "GrayDoc.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
IMPLEMENT_DYNCREATE(CGrayDoc,CImageDoc)
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CGrayDoc::CGrayDoc()
{
m_bGray = TRUE;
}
CGrayDoc::~CGrayDoc()
{
}
BOOL CGrayDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if(!CImageDoc::OnOpenDocument(lpszPathName))
return FALSE;
if(m_hDIB==NULL)
return FALSE;
LPSTR lpbi=(LPSTR)::GlobalLock((HGLOBAL)m_hDIB);
WORD wBitCount; // DIB bit count
DWORD dwCompression;
if (IS_WIN30_DIB(lpbi)) //Windows 3.0位图
{
wBitCount = ((LPBITMAPINFOHEADER)lpbi)->biBitCount;
dwCompression=((LPBITMAPINFOHEADER)lpbi)->biCompression;
}
else //OS/2位图
{
wBitCount = ((LPBITMAPCOREHEADER)lpbi)->bcBitCount;
dwCompression=BI_RGB; //未压缩
}
::GlobalUnlock((HGLOBAL)m_hDIB);
if(wBitCount != 8 || dwCompression != BI_RGB)
{
AfxMessageBox("不是256级灰度位图");
return FALSE;
}
else
{
m_bGray=TRUE;
return TRUE;
}
}
BOOL CGrayDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
return CImageDoc::OnSaveDocument(lpszPathName);
}