forked from chrisguo/beijing_fushengji
-
Notifications
You must be signed in to change notification settings - Fork 1
/
dib256.h
executable file
·93 lines (76 loc) · 3.01 KB
/
dib256.h
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1998 by Jörg König
// All rights reserved
//
// This file is part of the completely free tetris clone "CGTetris".
//
// This is free software.
// You may redistribute it by any means providing it is not sold for profit
// without the authors written consent.
//
// No warrantee of any kind, expressed or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date. I can be reached as follows:
// [email protected] (company site)
// [email protected] (private site)
/////////////////////////////////////////////////////////////////////////////
#ifndef DIB256_h
#define DIB256_h
class CDIBitmap
{
friend class CBmpPalette;
BITMAPINFO * m_pInfo;
BYTE * m_pPixels;
CBmpPalette * m_pPal;
BOOL m_bIsPadded;
public: //constructors
CDIBitmap();
virtual ~CDIBitmap();
private:
CDIBitmap( const CDIBitmap& dbmp );
public: // attributes
BITMAPINFO * GetHeaderPtr() const;
BYTE * GetPixelPtr() const;
RGBQUAD * GetColorTablePtr() const;
int GetWidth() const;
int GetHeight() const;
CBmpPalette * GetPalette() { return m_pPal; }
public: // operations
BOOL CreatePalette(); // auto. made by "Load()" and "CreateFromBitmap()"
void ClearPalette(); // destroy the palette associated with this image
BOOL CreateFromBitmap( CDC *, CBitmap * );
BOOL LoadResource(LPCTSTR ID);
BOOL LoadResource(UINT ID) { return LoadResource(MAKEINTRESOURCE(ID)); }
BOOL LoadBitmap(UINT ID) { return LoadResource(ID); }
BOOL LoadBitmap(LPCTSTR ID) { return LoadResource(ID); }
void DestroyBitmap();
BOOL DeleteObject() { DestroyBitmap(); return TRUE; }
public: // overridables
// draw the bitmap at the specified location
virtual void DrawDIB( CDC * pDC, int x=0, int y=0 );
// draw the bitmap and stretch/compress it to the desired size
virtual void DrawDIB( CDC * pDC, int x, int y, int width, int height );
// draw parts of the dib into a given area of the DC
virtual int DrawDIB( CDC * pDC, CRect & rectDC, CRect & rectDIB );
// load a bitmap from disk
virtual BOOL Load( CFile * pFile );
virtual BOOL Load( const CString & );
// save the bitmap to disk
virtual BOOL Save( CFile * pFile );
virtual BOOL Save( const CString & );
protected:
int GetPalEntries() const;
int GetPalEntries( BITMAPINFOHEADER& infoHeader ) const;
DWORD GetBitsPerPixel() const;
DWORD LastByte( DWORD BitsPerPixel, DWORD PixelCount ) const;
DWORD GetBytesPerLine( DWORD BitsPerPixel, DWORD Width ) const;
BOOL PadBits();
BOOL UnPadBits();
WORD GetColorCount() const;
};
#include "dibpal.h"
#endif // DIB256_h