1 | /* $Id: dibsect.h,v 1.12 2000-02-10 00:36:10 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_ONLY
|
---|
12 | typedef struct
|
---|
13 | {
|
---|
14 | BYTE rgbBlue;
|
---|
15 | BYTE rgbGreen;
|
---|
16 | BYTE rgbRed;
|
---|
17 | BYTE rgbReserved;
|
---|
18 | } RGBQUAD, *LPRGBQUAD;
|
---|
19 | #else
|
---|
20 | #define BITMAPINFO2 DWORD
|
---|
21 | #endif
|
---|
22 |
|
---|
23 | #define FLIP_VERT 1
|
---|
24 | #define FLIP_HOR 2
|
---|
25 |
|
---|
26 | typedef struct {
|
---|
27 | DWORD biSize;
|
---|
28 | LONG biWidth;
|
---|
29 | LONG biHeight;
|
---|
30 | WORD biPlanes;
|
---|
31 | WORD biBitCount;
|
---|
32 | DWORD biCompression;
|
---|
33 | DWORD biSizeImage;
|
---|
34 | LONG biXPelsPerMeter;
|
---|
35 | LONG biYPelsPerMeter;
|
---|
36 | DWORD biClrUsed;
|
---|
37 | DWORD biClrImportant;
|
---|
38 | } BITMAPINFOHEADER_W;
|
---|
39 |
|
---|
40 | typedef struct
|
---|
41 | {
|
---|
42 | INT bmType;
|
---|
43 | INT bmWidth;
|
---|
44 | INT bmHeight;
|
---|
45 | INT bmWidthBytes;
|
---|
46 | WORD bmPlanes;
|
---|
47 | WORD bmBitsPixel;
|
---|
48 | LPVOID bmBits;
|
---|
49 | } BITMAP_W, *LPBITMAP_W;
|
---|
50 |
|
---|
51 | #ifdef OS2_ONLY
|
---|
52 | typedef struct
|
---|
53 | {
|
---|
54 | BITMAP_W dsBm;
|
---|
55 | BITMAPINFOHEADER_W dsBmih;
|
---|
56 | DWORD dsBitfields[3];
|
---|
57 | HANDLE dshSection;
|
---|
58 | DWORD dsOffset;
|
---|
59 | } DIBSECTION,*LPDIBSECTION;
|
---|
60 | #endif
|
---|
61 |
|
---|
62 | class DIBSection
|
---|
63 | {
|
---|
64 | public:
|
---|
65 | DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD hSection, DWORD dwOffset, DWORD handle, int fFlip);
|
---|
66 | ~DIBSection();
|
---|
67 |
|
---|
68 | char *GetDIBObject() { return bmpBits; };
|
---|
69 | void SelectDIBObject(HDC hdc);
|
---|
70 | char GetBitCount();
|
---|
71 | void UnSelectDIBObject() { this->hdc = 0; };
|
---|
72 |
|
---|
73 | DWORD GetBitmapHandle() { return handle; };
|
---|
74 | DWORD GetRGBUsage() { return iUsage; };
|
---|
75 |
|
---|
76 | BOOL BitBlt(HDC hdcDest, int nXdest, int nYDest,
|
---|
77 | int nDestWidth, int nDestHeight,
|
---|
78 | int nXsrc, int nYSrc,
|
---|
79 | int nSrcWidth, int nSrcHeight,
|
---|
80 | DWORD Rop);
|
---|
81 |
|
---|
82 | int SetDIBColorTable(int startIdx, int cEntries, RGBQUAD *rgb);
|
---|
83 |
|
---|
84 | int SetDIBits(HDC hdc, HBITMAP hbitmap, UINT startscan, UINT
|
---|
85 | lines, const VOID *bits, BITMAPINFOHEADER_W *pbmi,
|
---|
86 | UINT coloruse);
|
---|
87 |
|
---|
88 | int GetDIBSection(int iSize , void *lpBuffer);
|
---|
89 |
|
---|
90 | static DIBSection *getSection() { return section; } ;
|
---|
91 | static DIBSection *find(DWORD handle);
|
---|
92 | static DIBSection *findHDC(HDC hdc);
|
---|
93 | static void deleteSection(DWORD handle);
|
---|
94 | protected:
|
---|
95 |
|
---|
96 | private:
|
---|
97 | DWORD handle, iUsage;
|
---|
98 | DWORD hSection;
|
---|
99 | HWND hwndParent;
|
---|
100 | HDC hdc;
|
---|
101 | char *bmpBits;
|
---|
102 | BOOL fFlip;
|
---|
103 | int bmpsize;
|
---|
104 | DIBSECTION dibinfo;
|
---|
105 |
|
---|
106 | BITMAPINFO2 *pOS2bmp;
|
---|
107 | // Linked list management
|
---|
108 | DIBSection* next; // Next DIB section
|
---|
109 | static DIBSection* section; // List of DIB sections
|
---|
110 | };
|
---|
111 |
|
---|
112 | #endif
|
---|
113 |
|
---|
114 |
|
---|