| 1 | /* $Id: dibsect.h,v 1.22 2000-11-09 18:16:56 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 |
|
|---|
| 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_ONLY
|
|---|
| 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);
|
|---|
| 100 | void sync(DWORD xDst, DWORD yDst, DWORD widthDst, DWORD heightDst, PVOID bits);
|
|---|
| 101 | int SetDIBColorTable(int startIdx, int cEntries, RGBQUAD *rgb);
|
|---|
| 102 | int SetDIBColorTable(int startIdx, int cEntries, PALETTEENTRY *rgb);
|
|---|
| 103 |
|
|---|
| 104 | int SetDIBits(HDC hdc, HBITMAP hbitmap, UINT startscan, UINT
|
|---|
| 105 | lines, const VOID *bits, BITMAPINFOHEADER_W *pbmi,
|
|---|
| 106 | UINT coloruse);
|
|---|
| 107 |
|
|---|
| 108 | int GetDIBSection(int iSize , void *lpBuffer);
|
|---|
| 109 |
|
|---|
| 110 | static DIBSection *getSection() { return section; } ;
|
|---|
| 111 | static DIBSection *find(DWORD handle);
|
|---|
| 112 | static DIBSection *findHDC(HDC hdc);
|
|---|
| 113 | static void deleteSection(DWORD handle);
|
|---|
| 114 | protected:
|
|---|
| 115 |
|
|---|
| 116 | private:
|
|---|
| 117 | DWORD handle, iUsage;
|
|---|
| 118 | DWORD hSection, dwOffset;
|
|---|
| 119 | HWND hwndParent;
|
|---|
| 120 | HDC hdc;
|
|---|
| 121 | char *bmpBits, *bmpBitsDblBuffer;
|
|---|
| 122 | BOOL fFlip;
|
|---|
| 123 | int bmpsize, os2bmphdrsize;
|
|---|
| 124 | DIBSECTION dibinfo;
|
|---|
| 125 |
|
|---|
| 126 | BITMAPINFO2 *pOS2bmp;
|
|---|
| 127 | // Linked list management
|
|---|
| 128 | DIBSection* next; // Next DIB section
|
|---|
| 129 | static DIBSection* section; // List of DIB sections
|
|---|
| 130 | };
|
|---|
| 131 |
|
|---|
| 132 | #endif
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|