source: trunk/src/gdi32/dibsect.h@ 6502

Last change on this file since 6502 was 5825, checked in by sandervl, 24 years ago

Set/GetDIBColorTable fixes + SelectPalette hack

File size: 3.8 KB
Line 
1/* $Id: dibsect.h,v 1.25 2001-05-29 09:45:21 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
12typedef struct
13{
14 BYTE rgbBlue;
15 BYTE rgbGreen;
16 BYTE rgbRed;
17 BYTE rgbReserved;
18} RGBQUAD, *LPRGBQUAD;
19
20typedef 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
32typedef 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
46typedef 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
57typedef struct {
58 BITMAPINFOHEADER_W bmiHeader;
59 RGBQUAD bmiColors[1];
60} BITMAPINFO_W;
61typedef BITMAPINFO *LPBITMAPINFO;
62
63#ifdef OS2_ONLY
64#define DIB_RGB_COLORS 0
65#define DIB_PAL_COLORS 1
66
67typedef 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
77class DIBSection
78{
79public:
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);
115protected:
116
117private:
118 DWORD handle, iUsage;
119 DWORD hSection, dwOffset;
120 HWND hwndParent;
121 HDC hdc;
122 char *bmpBits, *bmpBitsDblBuffer;
123 BOOL fFlip;
124 int bmpsize, os2bmphdrsize;
125 DIBSECTION dibinfo;
126
127 BITMAPINFO2 *pOS2bmp;
128 // Linked list management
129 DIBSection* next; // Next DIB section
130 static DIBSection* section; // List of DIB sections
131};
132
133#endif
134
135
Note: See TracBrowser for help on using the repository browser.