1 | /* $Id: dibsect.h,v 1.27 2003-11-14 17:31:47 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * GDI32 DIB sections
|
---|
5 | * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
6 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
7 | */
|
---|
8 | #ifndef __DIBSECT_H__
|
---|
9 | #define __DIBSECT_H__
|
---|
10 |
|
---|
11 | #ifdef OS2_INCLUDED
|
---|
12 | typedef struct
|
---|
13 | {
|
---|
14 | BYTE rgbBlue;
|
---|
15 | BYTE rgbGreen;
|
---|
16 | BYTE rgbRed;
|
---|
17 | BYTE rgbReserved;
|
---|
18 | } RGBQUAD, *LPRGBQUAD;
|
---|
19 |
|
---|
20 | typedef struct tagPALETTEENTRY
|
---|
21 | {
|
---|
22 | BYTE peRed, peGreen, peBlue, peFlags;
|
---|
23 | } PALETTEENTRY, *PPALETTEENTRY, *LPPALETTEENTRY;
|
---|
24 |
|
---|
25 | #else
|
---|
26 | #define BITMAPINFO2 DWORD
|
---|
27 | #endif
|
---|
28 |
|
---|
29 | #define FLIP_VERT 1
|
---|
30 | #define FLIP_HOR 2
|
---|
31 |
|
---|
32 | typedef struct {
|
---|
33 | DWORD biSize;
|
---|
34 | LONG biWidth;
|
---|
35 | LONG biHeight;
|
---|
36 | WORD biPlanes;
|
---|
37 | WORD biBitCount;
|
---|
38 | DWORD biCompression;
|
---|
39 | DWORD biSizeImage;
|
---|
40 | LONG biXPelsPerMeter;
|
---|
41 | LONG biYPelsPerMeter;
|
---|
42 | DWORD biClrUsed;
|
---|
43 | DWORD biClrImportant;
|
---|
44 | } BITMAPINFOHEADER_W;
|
---|
45 |
|
---|
46 | typedef struct
|
---|
47 | {
|
---|
48 | INT bmType;
|
---|
49 | INT bmWidth;
|
---|
50 | INT bmHeight;
|
---|
51 | INT bmWidthBytes;
|
---|
52 | WORD bmPlanes;
|
---|
53 | WORD bmBitsPixel;
|
---|
54 | LPVOID bmBits;
|
---|
55 | } BITMAP_W, *LPBITMAP_W;
|
---|
56 |
|
---|
57 | typedef struct {
|
---|
58 | BITMAPINFOHEADER_W bmiHeader;
|
---|
59 | RGBQUAD bmiColors[1];
|
---|
60 | } BITMAPINFO_W;
|
---|
61 | typedef BITMAPINFO *LPBITMAPINFO;
|
---|
62 |
|
---|
63 | #ifdef OS2_INCLUDED
|
---|
64 | #define DIB_RGB_COLORS 0
|
---|
65 | #define DIB_PAL_COLORS 1
|
---|
66 |
|
---|
67 | typedef struct
|
---|
68 | {
|
---|
69 | BITMAP_W dsBm;
|
---|
70 | BITMAPINFOHEADER_W dsBmih;
|
---|
71 | DWORD dsBitfields[3];
|
---|
72 | HANDLE dshSection;
|
---|
73 | DWORD dsOffset;
|
---|
74 | } DIBSECTION,*LPDIBSECTION;
|
---|
75 | #endif
|
---|
76 |
|
---|
77 | class DIBSection
|
---|
78 | {
|
---|
79 | public:
|
---|
80 | DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD hSection, DWORD dwOffset, DWORD handle, int fFlip);
|
---|
81 | ~DIBSection();
|
---|
82 |
|
---|
83 | char *GetDIBObject() { return bmpBits; };
|
---|
84 | void SelectDIBObject(HDC hdc);
|
---|
85 | int GetBitCount();
|
---|
86 | int GetHeight();
|
---|
87 | int GetWidth();
|
---|
88 | void UnSelectDIBObject() { this->hdc = 0; };
|
---|
89 |
|
---|
90 | DWORD GetBitmapHandle() { return handle; };
|
---|
91 | void SetBitmapHandle(DWORD bmphandle) { handle = bmphandle; };
|
---|
92 | DWORD GetRGBUsage() { return iUsage; };
|
---|
93 |
|
---|
94 | BOOL BitBlt(HDC hdcDest, int nXdest, int nYDest,
|
---|
95 | int nDestWidth, int nDestHeight,
|
---|
96 | int nXsrc, int nYSrc,
|
---|
97 | int nSrcWidth, int nSrcHeight,
|
---|
98 | DWORD Rop);
|
---|
99 | void sync(HDC hdc, DWORD nYdest, DWORD nDestHeight, BOOL orgYInversion = TRUE);
|
---|
100 | void sync(DWORD xDst, DWORD yDst, DWORD widthDst, DWORD heightDst, PVOID bits);
|
---|
101 | int SetDIBColorTable(int startIdx, int cEntries, RGBQUAD *rgb);
|
---|
102 | int GetDIBColorTable(int startIdx, int cEntries, RGBQUAD *rgb);
|
---|
103 | int SetDIBColorTable(int startIdx, int cEntries, PALETTEENTRY *rgb);
|
---|
104 |
|
---|
105 | int SetDIBits(HDC hdc, HBITMAP hbitmap, UINT startscan, UINT
|
---|
106 | lines, const VOID *bits, BITMAPINFOHEADER_W *pbmi,
|
---|
107 | UINT coloruse);
|
---|
108 |
|
---|
109 | int GetDIBSection(int iSize , void *lpBuffer);
|
---|
110 |
|
---|
111 | static DIBSection *getSection() { return section; } ;
|
---|
112 | static DIBSection *findObj(HANDLE handle);
|
---|
113 | static DIBSection *findHDC(HDC hdc);
|
---|
114 | static void deleteSection(HANDLE handle);
|
---|
115 |
|
---|
116 | static void initDIBSection();
|
---|
117 |
|
---|
118 | static void lock() { EnterCriticalSection(&dibcritsect); };
|
---|
119 | static void unlock() { LeaveCriticalSection(&dibcritsect); };
|
---|
120 |
|
---|
121 | protected:
|
---|
122 |
|
---|
123 | private:
|
---|
124 | DWORD handle, iUsage;
|
---|
125 | DWORD hSection, dwOffset;
|
---|
126 | HWND hwndParent;
|
---|
127 | HDC hdc;
|
---|
128 | char *bmpBits, *bmpBitsDblBuffer;
|
---|
129 | BOOL fFlip;
|
---|
130 | int bmpsize, os2bmphdrsize;
|
---|
131 | DIBSECTION dibinfo;
|
---|
132 |
|
---|
133 | BITMAPINFO2 *pOS2bmp;
|
---|
134 | // Linked list management
|
---|
135 | DIBSection* next; // Next DIB section
|
---|
136 | static DIBSection* section; // List of DIB sections
|
---|
137 |
|
---|
138 | static CRITICAL_SECTION dibcritsect;
|
---|
139 | };
|
---|
140 |
|
---|
141 | #define DIBSECTION_MARK_INVALID(a)
|
---|
142 | #define DIBSECTION_CHECK_IF_DIRTY(a)
|
---|
143 |
|
---|
144 | #endif
|
---|
145 |
|
---|
146 |
|
---|