| 1 | /* $Id: dibsect.h,v 1.21 2000-10-07 09:03:50 hugh 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 | typedef struct { | 
|---|
| 52 | BITMAPINFOHEADER_W bmiHeader; | 
|---|
| 53 | RGBQUAD bmiColors[1]; | 
|---|
| 54 | } BITMAPINFO_W; | 
|---|
| 55 | typedef BITMAPINFO *LPBITMAPINFO; | 
|---|
| 56 |  | 
|---|
| 57 | #ifdef OS2_ONLY | 
|---|
| 58 | #define DIB_RGB_COLORS   0 | 
|---|
| 59 | #define DIB_PAL_COLORS   1 | 
|---|
| 60 |  | 
|---|
| 61 | typedef struct | 
|---|
| 62 | { | 
|---|
| 63 | BITMAP_W   dsBm; | 
|---|
| 64 | BITMAPINFOHEADER_W dsBmih; | 
|---|
| 65 | DWORD     dsBitfields[3]; | 
|---|
| 66 | HANDLE    dshSection; | 
|---|
| 67 | DWORD     dsOffset; | 
|---|
| 68 | } DIBSECTION,*LPDIBSECTION; | 
|---|
| 69 | #endif | 
|---|
| 70 |  | 
|---|
| 71 | class DIBSection | 
|---|
| 72 | { | 
|---|
| 73 | public: | 
|---|
| 74 | DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD hSection, DWORD dwOffset, DWORD handle, int fFlip); | 
|---|
| 75 | ~DIBSection(); | 
|---|
| 76 |  | 
|---|
| 77 | char *GetDIBObject()           { return bmpBits;  }; | 
|---|
| 78 | void  SelectDIBObject(HDC hdc); | 
|---|
| 79 | int   GetBitCount(); | 
|---|
| 80 | int   GetHeight(); | 
|---|
| 81 | int   GetWidth(); | 
|---|
| 82 | void  UnSelectDIBObject()      { this->hdc = 0;   }; | 
|---|
| 83 |  | 
|---|
| 84 | DWORD GetBitmapHandle()      { return handle; }; | 
|---|
| 85 | void  SetBitmapHandle(DWORD bmphandle) { handle = bmphandle; }; | 
|---|
| 86 | DWORD GetRGBUsage()            { return iUsage; }; | 
|---|
| 87 |  | 
|---|
| 88 | BOOL  BitBlt(HDC hdcDest, int nXdest, int nYDest, | 
|---|
| 89 | int nDestWidth, int nDestHeight, | 
|---|
| 90 | int nXsrc, int nYSrc, | 
|---|
| 91 | int nSrcWidth, int nSrcHeight, | 
|---|
| 92 | DWORD Rop); | 
|---|
| 93 | void  sync(HDC hdc, DWORD nYdest, DWORD nDestHeight); | 
|---|
| 94 | void  sync(DWORD xDst, DWORD yDst, DWORD widthDst, DWORD heightDst, PVOID bits); | 
|---|
| 95 | int  SetDIBColorTable(int startIdx, int cEntries, RGBQUAD *rgb); | 
|---|
| 96 |  | 
|---|
| 97 | int  SetDIBits(HDC hdc, HBITMAP hbitmap, UINT startscan, UINT | 
|---|
| 98 | lines, const VOID *bits, BITMAPINFOHEADER_W *pbmi, | 
|---|
| 99 | UINT coloruse); | 
|---|
| 100 |  | 
|---|
| 101 | int  GetDIBSection(int iSize , void *lpBuffer); | 
|---|
| 102 |  | 
|---|
| 103 | static DIBSection *getSection() { return section; } ; | 
|---|
| 104 | static DIBSection *find(DWORD handle); | 
|---|
| 105 | static DIBSection *findHDC(HDC hdc); | 
|---|
| 106 | static       void  deleteSection(DWORD handle); | 
|---|
| 107 | protected: | 
|---|
| 108 |  | 
|---|
| 109 | private: | 
|---|
| 110 | DWORD handle, iUsage; | 
|---|
| 111 | DWORD hSection, dwOffset; | 
|---|
| 112 | HWND  hwndParent; | 
|---|
| 113 | HDC   hdc; | 
|---|
| 114 | char *bmpBits, *bmpBitsDblBuffer; | 
|---|
| 115 | BOOL  fFlip; | 
|---|
| 116 | int   bmpsize, os2bmphdrsize; | 
|---|
| 117 | DIBSECTION  dibinfo; | 
|---|
| 118 |  | 
|---|
| 119 | BITMAPINFO2 *pOS2bmp; | 
|---|
| 120 | // Linked list management | 
|---|
| 121 | DIBSection*    next;                   // Next DIB section | 
|---|
| 122 | static    DIBSection*    section;                // List of DIB sections | 
|---|
| 123 | }; | 
|---|
| 124 |  | 
|---|
| 125 | #endif | 
|---|
| 126 |  | 
|---|
| 127 |  | 
|---|