1 | /* $Id: dibsect.cpp,v 1.61 2001-12-20 19:57:01 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * GDI32 DIB sections
|
---|
5 | *
|
---|
6 | * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
7 | * Copyright 1998 Patrick Haller
|
---|
8 | *
|
---|
9 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
10 | *
|
---|
11 | * NOTE:
|
---|
12 | * This is not a complete solution for CreateDIBSection, but enough for Quake 2!
|
---|
13 | *
|
---|
14 | */
|
---|
15 | #define INCL_GPI
|
---|
16 | #define INCL_WIN
|
---|
17 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
---|
18 | #include <stdlib.h>
|
---|
19 | #include <string.h>
|
---|
20 | #include <win32type.h>
|
---|
21 | #include <misc.h>
|
---|
22 | #define OS2_ONLY
|
---|
23 | #include "dibsect.h"
|
---|
24 | #include <vmutex.h>
|
---|
25 | #include <win32api.h>
|
---|
26 | #include <winconst.h>
|
---|
27 | #include <winuser32.h>
|
---|
28 | #include <cpuhlp.h>
|
---|
29 | #include <dcdata.h>
|
---|
30 | #include "oslibgpi.h"
|
---|
31 | #include "rgbcvt.h"
|
---|
32 |
|
---|
33 | #define DBG_LOCALLOG DBG_dibsect
|
---|
34 | #include "dbglocal.h"
|
---|
35 |
|
---|
36 | static VMutex dibMutex;
|
---|
37 |
|
---|
38 | //******************************************************************************
|
---|
39 | //******************************************************************************
|
---|
40 | DIBSection::DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD hSection, DWORD dwOffset, DWORD handle, int fFlip)
|
---|
41 | : bmpBits(NULL), pOS2bmp(NULL), next(NULL), bmpBitsDblBuffer(NULL),
|
---|
42 | hdc(0), hwndParent(0)
|
---|
43 | {
|
---|
44 | int palsize=0;
|
---|
45 |
|
---|
46 | bmpsize = pbmi->biWidth;
|
---|
47 | /* @@@PH 98/06/07 -- high-color bitmaps don't have palette */
|
---|
48 |
|
---|
49 | this->fFlip = fFlip;
|
---|
50 | os2bmphdrsize = sizeof(BITMAPINFO2);
|
---|
51 |
|
---|
52 | switch(pbmi->biBitCount)
|
---|
53 | {
|
---|
54 | case 1:
|
---|
55 | bmpsize = ((bmpsize + 31) & ~31) / 8;
|
---|
56 | palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
|
---|
57 | os2bmphdrsize += palsize;
|
---|
58 | break;
|
---|
59 | case 4:
|
---|
60 | bmpsize = ((bmpsize + 7) & ~7) / 2;
|
---|
61 | palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
|
---|
62 | os2bmphdrsize += palsize;
|
---|
63 | break;
|
---|
64 | case 8:
|
---|
65 | palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
|
---|
66 | os2bmphdrsize += palsize;
|
---|
67 | bmpsize = (bmpsize + 3) & ~3;
|
---|
68 | break;
|
---|
69 | case 16:
|
---|
70 | bmpsize *= 2;
|
---|
71 | bmpsize = (bmpsize + 3) & ~3;
|
---|
72 | break;
|
---|
73 | case 24:
|
---|
74 | bmpsize *= 3;
|
---|
75 | bmpsize = (bmpsize + 3) & ~3;
|
---|
76 | break;
|
---|
77 | case 32:
|
---|
78 | bmpsize *= 4;
|
---|
79 | break;
|
---|
80 | default:
|
---|
81 | dprintf(("Unsupported nr of bits %d", pbmi->biBitCount));
|
---|
82 | DebugInt3();
|
---|
83 | break;
|
---|
84 | }
|
---|
85 |
|
---|
86 | this->hSection = hSection;
|
---|
87 | this->dwOffset = dwOffset;
|
---|
88 | if(hSection) {
|
---|
89 | bmpBits = (char *)MapViewOfFile(hSection, FILE_MAP_ALL_ACCESS_W, 0, dwOffset, bmpsize*pbmi->biHeight);
|
---|
90 | if(!bmpBits) {
|
---|
91 | dprintf(("Dibsection: mapViewOfFile %x failed!", hSection));
|
---|
92 | DebugInt3();
|
---|
93 | }
|
---|
94 | }
|
---|
95 | if(!bmpBits) {
|
---|
96 | DosAllocMem((PPVOID)&bmpBits, bmpsize*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT);
|
---|
97 | }
|
---|
98 | memset(bmpBits, 0, bmpsize*pbmi->biHeight);
|
---|
99 |
|
---|
100 | pOS2bmp = (BITMAPINFO2 *)malloc(os2bmphdrsize);
|
---|
101 |
|
---|
102 | memset(pOS2bmp, /* set header + palette entries to zero */
|
---|
103 | 0,
|
---|
104 | os2bmphdrsize);
|
---|
105 |
|
---|
106 | pOS2bmp->cbFix = sizeof(BITMAPINFO2) - sizeof(RGB2);
|
---|
107 | pOS2bmp->cx = pbmi->biWidth;
|
---|
108 | pOS2bmp->cy = pbmi->biHeight;
|
---|
109 | pOS2bmp->cPlanes = pbmi->biPlanes;
|
---|
110 | pOS2bmp->cBitCount = pbmi->biBitCount;
|
---|
111 | pOS2bmp->ulCompression = pbmi->biCompression; //same as OS/2 (uncompressed, rle8, rle4)
|
---|
112 | //SvL: Ignore BI_BITFIELDS_W type (GpiDrawBits fails otherwise)
|
---|
113 | if(pOS2bmp->ulCompression == BI_BITFIELDS_W) {
|
---|
114 | pOS2bmp->ulCompression = 0;
|
---|
115 | }
|
---|
116 | pOS2bmp->cbImage = pbmi->biSizeImage;
|
---|
117 | dprintf(("handle %x", handle));
|
---|
118 | dprintf(("pOS2bmp->cx %d\n", pOS2bmp->cx));
|
---|
119 | dprintf(("pOS2bmp->cy %d\n", pOS2bmp->cy));
|
---|
120 | dprintf(("pOS2bmp->cPlanes %d\n", pOS2bmp->cPlanes));
|
---|
121 | dprintf(("pOS2bmp->cBitCount %d\n", pOS2bmp->cBitCount));
|
---|
122 | dprintf(("pOS2bmp->ulCompression %d\n", pOS2bmp->ulCompression));
|
---|
123 | dprintf(("pOS2bmp->cbImage %d\n", pOS2bmp->cbImage));
|
---|
124 | dprintf(("Bits at %x, size %d",bmpBits, bmpsize*pbmi->biHeight));
|
---|
125 |
|
---|
126 | // clear DIBSECTION structure
|
---|
127 | memset(&dibinfo, 0, sizeof(dibinfo));
|
---|
128 |
|
---|
129 | // copy BITMAPINFOHEADER data into DIBSECTION structure
|
---|
130 | memcpy(&dibinfo.dsBmih, pbmi, sizeof(*pbmi));
|
---|
131 | dibinfo.dsBm.bmType = 0;
|
---|
132 | dibinfo.dsBm.bmWidth = pbmi->biWidth;
|
---|
133 | dibinfo.dsBm.bmHeight = pbmi->biHeight;
|
---|
134 | dibinfo.dsBm.bmWidthBytes= bmpsize;
|
---|
135 | dibinfo.dsBm.bmPlanes = pbmi->biPlanes;
|
---|
136 | dibinfo.dsBm.bmBitsPixel = pbmi->biBitCount;
|
---|
137 | dibinfo.dsBm.bmBits = bmpBits;
|
---|
138 |
|
---|
139 | dibinfo.dshSection = hSection;
|
---|
140 | dibinfo.dsOffset = dwOffset;
|
---|
141 |
|
---|
142 | if(iUsage == DIB_PAL_COLORS || pbmi->biBitCount <= 8)
|
---|
143 | {
|
---|
144 | dibinfo.dsBitfields[0] = dibinfo.dsBitfields[1] = dibinfo.dsBitfields[2] = 0;
|
---|
145 | if(palsize) {
|
---|
146 | SetDIBColorTable(0, (1 << pbmi->biBitCount), (RGBQUAD *)(pbmi+1));
|
---|
147 | }
|
---|
148 | }
|
---|
149 | else {
|
---|
150 | switch(pbmi->biBitCount)
|
---|
151 | {
|
---|
152 | case 16:
|
---|
153 | dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS_W) ? *(DWORD *)pColors : 0x7c00;
|
---|
154 | dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 1) : 0x03e0;
|
---|
155 | dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 2) : 0x001f;
|
---|
156 | break;
|
---|
157 |
|
---|
158 | case 24:
|
---|
159 | case 32:
|
---|
160 | dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS_W) ? *(DWORD *)pColors : 0xff0000;
|
---|
161 | dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 1) : 0x00ff00;
|
---|
162 | dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 2) : 0x0000ff;
|
---|
163 | if(dibinfo.dsBitfields[0] != 0xff0000 && dibinfo.dsBitfields[1] != 0xff00 && dibinfo.dsBitfields[2] != 0xff) {
|
---|
164 | dprintf(("DIBSection: unsupported bitfields for 32 bits bitmap!!"));
|
---|
165 | }
|
---|
166 | break;
|
---|
167 | }
|
---|
168 | dprintf(("BI_BITFIELDS_W %x %x %x", dibinfo.dsBitfields[0], dibinfo.dsBitfields[1], dibinfo.dsBitfields[2]));
|
---|
169 | }
|
---|
170 | //double buffer for rgb 555 dib sections (for conversion) or flipped sections
|
---|
171 | if(dibinfo.dsBitfields[1] == 0x03e0 || (fFlip & FLIP_VERT)) {
|
---|
172 | DosAllocMem((PPVOID)&bmpBitsDblBuffer, bmpsize*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT);
|
---|
173 | }
|
---|
174 |
|
---|
175 | this->handle = handle;
|
---|
176 | this->iUsage = iUsage;
|
---|
177 |
|
---|
178 | dibMutex.enter();
|
---|
179 | if(section == NULL)
|
---|
180 | {
|
---|
181 | dprintf(("section was NULL\n"));
|
---|
182 | section = this;
|
---|
183 | }
|
---|
184 | else
|
---|
185 | {
|
---|
186 | DIBSection *dsect = section;
|
---|
187 | dprintf2(("Increment section starting at %08X\n",dsect));
|
---|
188 |
|
---|
189 | while ( (dsect->next != this) &&
|
---|
190 | (dsect->next != NULL) )
|
---|
191 | {
|
---|
192 | //// dprintf2(("Increment section to %08X\n",dsect->next));
|
---|
193 | dsect = dsect->next;
|
---|
194 | }
|
---|
195 | dsect->next = this;
|
---|
196 | }
|
---|
197 | dibMutex.leave();
|
---|
198 | }
|
---|
199 | //******************************************************************************
|
---|
200 | //******************************************************************************
|
---|
201 | DIBSection::~DIBSection()
|
---|
202 | {
|
---|
203 | dprintf(("Delete DIBSection %x", handle));
|
---|
204 |
|
---|
205 | if(hSection) {
|
---|
206 | UnmapViewOfFile(bmpBits);
|
---|
207 | }
|
---|
208 | else
|
---|
209 | if(bmpBits)
|
---|
210 | DosFreeMem(bmpBits);
|
---|
211 |
|
---|
212 | if(bmpBitsDblBuffer)
|
---|
213 | DosFreeMem(bmpBitsDblBuffer);
|
---|
214 |
|
---|
215 | if(pOS2bmp)
|
---|
216 | free(pOS2bmp);
|
---|
217 |
|
---|
218 | dibMutex.enter();
|
---|
219 | if(section == this)
|
---|
220 | {
|
---|
221 | section = this->next;
|
---|
222 | }
|
---|
223 | else
|
---|
224 | {
|
---|
225 | DIBSection *dsect = section;
|
---|
226 |
|
---|
227 | while(dsect->next != this)
|
---|
228 | {
|
---|
229 | dsect = dsect->next;
|
---|
230 | }
|
---|
231 | dsect->next = this->next;
|
---|
232 | }
|
---|
233 | dibMutex.leave();
|
---|
234 | }
|
---|
235 | //******************************************************************************
|
---|
236 | //******************************************************************************
|
---|
237 | int DIBSection::SetDIBits(HDC hdc, HBITMAP hbitmap, UINT startscan, UINT
|
---|
238 | lines, const VOID *bits, BITMAPINFOHEADER_W *pbmi,
|
---|
239 | UINT coloruse)
|
---|
240 | {
|
---|
241 | lines = (int)lines >= 0 ? (int)lines : (int)-lines;
|
---|
242 | int palsize=0;
|
---|
243 |
|
---|
244 | bmpsize = pbmi->biWidth;
|
---|
245 | os2bmphdrsize = sizeof(BITMAPINFO2);
|
---|
246 |
|
---|
247 | switch(pbmi->biBitCount)
|
---|
248 | {
|
---|
249 | case 1:
|
---|
250 | bmpsize = ((bmpsize + 31) & ~31) / 8;
|
---|
251 | palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
|
---|
252 | os2bmphdrsize += palsize;
|
---|
253 | break;
|
---|
254 | case 4:
|
---|
255 | bmpsize = ((bmpsize + 7) & ~7) / 2;
|
---|
256 | palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
|
---|
257 | os2bmphdrsize += palsize;
|
---|
258 | break;
|
---|
259 | case 8:
|
---|
260 | palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
|
---|
261 | os2bmphdrsize += palsize;
|
---|
262 | bmpsize = (bmpsize + 3) & ~3;
|
---|
263 | break;
|
---|
264 | case 16:
|
---|
265 | bmpsize *= 2;
|
---|
266 | bmpsize = (bmpsize + 3) & ~3;
|
---|
267 | break;
|
---|
268 | case 24:
|
---|
269 | bmpsize *= 3;
|
---|
270 | bmpsize = (bmpsize + 3) & ~3;
|
---|
271 | break;
|
---|
272 | case 32:
|
---|
273 | bmpsize *= 4;
|
---|
274 | break;
|
---|
275 | }
|
---|
276 |
|
---|
277 | //SvL: TODO: Correct??
|
---|
278 | if(!hSection && pOS2bmp->cx != pbmi->biWidth && pOS2bmp->cy != pbmi->biHeight &&
|
---|
279 | pOS2bmp->cBitCount != pbmi->biBitCount)
|
---|
280 | {
|
---|
281 | char *oldbits = bmpBits;
|
---|
282 | int oldsize = dibinfo.dsBm.bmWidthBytes * dibinfo.dsBm.bmHeight;
|
---|
283 |
|
---|
284 | DosAllocMem((PPVOID)&bmpBits, bmpsize*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT);
|
---|
285 | memcpy(bmpBits, oldbits, min(oldsize, bmpsize*pbmi->biHeight));
|
---|
286 | DosFreeMem(oldbits);
|
---|
287 | }
|
---|
288 | pOS2bmp = (BITMAPINFO2 *)realloc(pOS2bmp, os2bmphdrsize);
|
---|
289 | pOS2bmp->cbFix = sizeof(BITMAPINFO2) - sizeof(RGB2);
|
---|
290 | pOS2bmp->cx = pbmi->biWidth;
|
---|
291 | pOS2bmp->cy = pbmi->biHeight;
|
---|
292 | pOS2bmp->cPlanes = pbmi->biPlanes;
|
---|
293 | pOS2bmp->cBitCount = pbmi->biBitCount;
|
---|
294 | pOS2bmp->ulCompression = pbmi->biCompression; //same as OS/2 (uncompressed, rle8, rle4)
|
---|
295 | //SvL: Ignore BI_BITFIELDS_W type (GpiDrawBits fails otherwise)
|
---|
296 | if(pOS2bmp->ulCompression == BI_BITFIELDS_W) {
|
---|
297 | pOS2bmp->ulCompression = 0;
|
---|
298 | }
|
---|
299 | pOS2bmp->cbImage = pbmi->biSizeImage;
|
---|
300 |
|
---|
301 | // clear DIBSECTION structure
|
---|
302 | memset(&dibinfo, 0, sizeof(dibinfo));
|
---|
303 |
|
---|
304 | // copy BITMAPINFOHEADER data into DIBSECTION structure
|
---|
305 | memcpy(&dibinfo.dsBmih, pbmi, sizeof(*pbmi));
|
---|
306 | dibinfo.dsBm.bmType = 0;
|
---|
307 | dibinfo.dsBm.bmWidth = pbmi->biWidth;
|
---|
308 | dibinfo.dsBm.bmHeight = pbmi->biHeight;
|
---|
309 | dibinfo.dsBm.bmWidthBytes= bmpsize;
|
---|
310 | dibinfo.dsBm.bmPlanes = pbmi->biPlanes;
|
---|
311 | dibinfo.dsBm.bmBitsPixel = pbmi->biBitCount;
|
---|
312 | dibinfo.dsBm.bmBits = bmpBits;
|
---|
313 |
|
---|
314 | dibinfo.dshSection = hSection;
|
---|
315 | dibinfo.dsOffset = dwOffset;
|
---|
316 |
|
---|
317 | if(coloruse == DIB_PAL_COLORS || pbmi->biBitCount <= 8)
|
---|
318 | {
|
---|
319 | dibinfo.dsBitfields[0] = dibinfo.dsBitfields[1] = dibinfo.dsBitfields[2] = 0;
|
---|
320 | }
|
---|
321 | else {
|
---|
322 | char *pColors = (char *)pbmi + 1;
|
---|
323 |
|
---|
324 | switch(pbmi->biBitCount)
|
---|
325 | {
|
---|
326 | case 16:
|
---|
327 | dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS_W) ? *(DWORD *)pColors : 0x7c00;
|
---|
328 | dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 1) : 0x03e0;
|
---|
329 | dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 2) : 0x001f;
|
---|
330 | break;
|
---|
331 |
|
---|
332 | case 24:
|
---|
333 | case 32:
|
---|
334 | dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS_W) ? *(DWORD *)pColors : 0xff0000;
|
---|
335 | dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 1) : 0x00ff00;
|
---|
336 | dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 2) : 0x0000ff;
|
---|
337 | if(dibinfo.dsBitfields[0] != 0xff0000 && dibinfo.dsBitfields[1] != 0xff00 && dibinfo.dsBitfields[2] != 0xff) {
|
---|
338 | dprintf(("DIBSection: unsupported bitfields for 32 bits bitmap!!"));
|
---|
339 | }
|
---|
340 | break;
|
---|
341 | }
|
---|
342 | dprintf(("BI_BITFIELDS_W %x %x %x", dibinfo.dsBitfields[0], dibinfo.dsBitfields[1], dibinfo.dsBitfields[2]));
|
---|
343 | }
|
---|
344 |
|
---|
345 | //double buffer for rgb 555 dib sections (for conversion) or flipped sections
|
---|
346 | if(dibinfo.dsBitfields[1] == 0x03e0 || (fFlip & FLIP_VERT)) {
|
---|
347 | if(bmpBitsDblBuffer) {
|
---|
348 | DosFreeMem(bmpBitsDblBuffer);
|
---|
349 | }
|
---|
350 | DosAllocMem((PPVOID)&bmpBitsDblBuffer, dibinfo.dsBm.bmWidthBytes*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT);
|
---|
351 | }
|
---|
352 |
|
---|
353 | dprintf(("DIBSection::SetDIBits (%d,%d), %d %d", pbmi->biWidth, pbmi->biHeight, pbmi->biBitCount, pbmi->biCompression));
|
---|
354 | if(palsize) {
|
---|
355 | SetDIBColorTable(0, 1 << pbmi->biBitCount, (RGBQUAD *)(pbmi+1));
|
---|
356 | }
|
---|
357 |
|
---|
358 | if(bits)
|
---|
359 | {
|
---|
360 | if(pOS2bmp->ulCompression == BCA_UNCOMP) {
|
---|
361 | int size = bmpsize*lines;
|
---|
362 | memcpy(bmpBits+bmpsize*startscan, bits, size);
|
---|
363 | }
|
---|
364 | else {
|
---|
365 | dprintf(("Compressed image!!"));
|
---|
366 | if(startscan != 0) {
|
---|
367 | dprintf(("WARNING: Compressed image & startscan != 0!!!!"));
|
---|
368 | }
|
---|
369 | memcpy(bmpBits, bits, pbmi->biSizeImage);
|
---|
370 | }
|
---|
371 | }
|
---|
372 | return(lines);
|
---|
373 | }
|
---|
374 | //******************************************************************************
|
---|
375 | //******************************************************************************
|
---|
376 | int DIBSection::SetDIBColorTable(int startIdx, int cEntries, RGBQUAD *rgb)
|
---|
377 | {
|
---|
378 | int i, end;
|
---|
379 |
|
---|
380 | dprintf(("SetDIBColorTable %d %d %x", startIdx, cEntries, rgb));
|
---|
381 |
|
---|
382 | if(pOS2bmp->cBitCount > 8) {
|
---|
383 | dprintf(("DIBSection::SetDIBColorTable: bpp > 8; ignore"));
|
---|
384 | return 0;
|
---|
385 | }
|
---|
386 |
|
---|
387 | end = startIdx + cEntries;
|
---|
388 | if(end > (1 << pOS2bmp->cBitCount)) {
|
---|
389 | end = (1 << pOS2bmp->cBitCount);
|
---|
390 | cEntries = end - startIdx;
|
---|
391 | }
|
---|
392 |
|
---|
393 | memcpy(&pOS2bmp->argbColor[startIdx], rgb, cEntries*sizeof(RGB2));
|
---|
394 |
|
---|
395 | for(i=startIdx;i<end;i++)
|
---|
396 | {
|
---|
397 | pOS2bmp->argbColor[i].fcOptions = 0;
|
---|
398 | #ifdef DEBUG_PALETTE
|
---|
399 | dprintf2(("Index %d : 0x%08X\n",i, *((ULONG*)(&pOS2bmp->argbColor[i])) ));
|
---|
400 | #endif
|
---|
401 | }
|
---|
402 | return(cEntries);
|
---|
403 | }
|
---|
404 | //******************************************************************************
|
---|
405 | //******************************************************************************
|
---|
406 | int DIBSection::SetDIBColorTable(int startIdx, int cEntries, PALETTEENTRY *palentry)
|
---|
407 | {
|
---|
408 | int i, end;
|
---|
409 |
|
---|
410 | if(pOS2bmp->cBitCount > 8) {
|
---|
411 | dprintf(("DIBSection::SetDIBColorTable: bpp > 8; ignore"));
|
---|
412 | return 0;
|
---|
413 | }
|
---|
414 |
|
---|
415 | end = startIdx + cEntries;
|
---|
416 | if(end > (1 << pOS2bmp->cBitCount)) {
|
---|
417 | end = (1 << pOS2bmp->cBitCount);
|
---|
418 | }
|
---|
419 | for(i=startIdx;i<end;i++)
|
---|
420 | {
|
---|
421 | pOS2bmp->argbColor[i].fcOptions = 0;
|
---|
422 | pOS2bmp->argbColor[i].bBlue = palentry[i].peBlue;
|
---|
423 | pOS2bmp->argbColor[i].bGreen = palentry[i].peGreen;
|
---|
424 | pOS2bmp->argbColor[i].bRed = palentry[i].peRed;
|
---|
425 | }
|
---|
426 |
|
---|
427 | return end - startIdx;
|
---|
428 | }
|
---|
429 | //******************************************************************************
|
---|
430 | //******************************************************************************
|
---|
431 | int DIBSection::GetDIBColorTable(int startIdx, int cEntries, RGBQUAD *rgb)
|
---|
432 | {
|
---|
433 | int i, end = startIdx + cEntries;
|
---|
434 |
|
---|
435 | if(pOS2bmp->cBitCount > 8) {
|
---|
436 | dprintf(("DIBSection::GetDIBColorTable: bpp > 8 -> return 0"));
|
---|
437 | return 0;
|
---|
438 | }
|
---|
439 | if(end > (1 << pOS2bmp->cBitCount)) {
|
---|
440 | end = (1 << pOS2bmp->cBitCount);
|
---|
441 | dprintf(("DIBSection::GetDIBColorTable: %d->%d", startIdx, end));
|
---|
442 | }
|
---|
443 | memcpy(rgb, &pOS2bmp->argbColor[startIdx], cEntries*sizeof(RGBQUAD));
|
---|
444 |
|
---|
445 | for(i=0;i<cEntries;i++) {
|
---|
446 | rgb[i].rgbReserved = 0;
|
---|
447 | }
|
---|
448 |
|
---|
449 | return end - startIdx;
|
---|
450 | }
|
---|
451 | //******************************************************************************
|
---|
452 | //******************************************************************************
|
---|
453 | BOOL DIBSection::BitBlt(HDC hdcDest, int nXdest, int nYdest, int nDestWidth,
|
---|
454 | int nDestHeight, int nXsrc, int nYsrc,
|
---|
455 | int nSrcWidth, int nSrcHeight, DWORD Rop)
|
---|
456 | {
|
---|
457 | HPS hps = (HPS)hdcDest;
|
---|
458 | POINTL point[4];
|
---|
459 | LONG rc, hdcHeight, hdcWidth;
|
---|
460 | PVOID bitmapBits = NULL;
|
---|
461 | int oldyinversion = 0;
|
---|
462 | BOOL fRestoryYInversion = FALSE, fFrameWindowDC = FALSE;
|
---|
463 | HWND hwndDest;
|
---|
464 | pDCData pHps;
|
---|
465 |
|
---|
466 | pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdcDest);
|
---|
467 | if(!pHps)
|
---|
468 | {
|
---|
469 | SetLastError(ERROR_INVALID_HANDLE_W);
|
---|
470 | return FALSE;
|
---|
471 | }
|
---|
472 |
|
---|
473 | hwndDest = WindowFromDC(hdcDest); //could return desktop window, so check that
|
---|
474 | if(hwndDest && pHps->hwnd && !pHps->isClient) {
|
---|
475 | fFrameWindowDC = TRUE;
|
---|
476 | }
|
---|
477 |
|
---|
478 | dprintf(("DIBSection::BitBlt %x %X (hps %x) %x to(%d,%d)(%d,%d) from (%d,%d)(%d,%d) rop %x flip %x",
|
---|
479 | handle, hdcDest, hps, hwndDest, nXdest, nYdest, nDestWidth, nDestHeight,
|
---|
480 | nXsrc, nYsrc, nSrcWidth, nSrcHeight, Rop, fFlip));
|
---|
481 |
|
---|
482 | if(hwndDest) {
|
---|
483 | RECT rect;
|
---|
484 |
|
---|
485 | if(fFrameWindowDC) {
|
---|
486 | GetWindowRect(hwndDest, &rect);
|
---|
487 | }
|
---|
488 | else GetClientRect(hwndDest, &rect);
|
---|
489 | hdcHeight = rect.bottom - rect.top;
|
---|
490 | hdcWidth = rect.right - rect.left;
|
---|
491 | }
|
---|
492 | else {
|
---|
493 | hdcHeight = pHps->bitmapHeight;
|
---|
494 | hdcWidth = pHps->bitmapWidth;
|
---|
495 | }
|
---|
496 |
|
---|
497 | //Don't clip destination size to destination DC size
|
---|
498 | //This messes up the two bitmaps in the opening window of Opera 6
|
---|
499 | //(choice between MDI & SDI interface)
|
---|
500 | #if 0
|
---|
501 | if(nXdest + nDestWidth > hdcWidth) {
|
---|
502 | nDestWidth = hdcWidth - nXdest;
|
---|
503 | }
|
---|
504 |
|
---|
505 | if(nYdest + nDestHeight > hdcHeight) {
|
---|
506 | nDestHeight = hdcHeight - nYdest;
|
---|
507 | }
|
---|
508 | #endif
|
---|
509 |
|
---|
510 | //win32 coordinates are relative to left top, OS/2 expects left bottom
|
---|
511 | //source rectangle is non-inclusive (top, right not included)
|
---|
512 | //destination rectangle is incl.-inclusive (everything included)
|
---|
513 |
|
---|
514 | point[0].x = nXdest;
|
---|
515 | point[0].y = hdcHeight - nYdest - nDestHeight;
|
---|
516 | point[1].x = nXdest + nDestWidth - 1;
|
---|
517 | point[1].y = hdcHeight - nYdest - 1;
|
---|
518 |
|
---|
519 | #if 0
|
---|
520 | //Don't check size here either. Let GpiDrawBits do that for us
|
---|
521 | if(nXsrc + nSrcWidth > pOS2bmp->cx) {
|
---|
522 | nSrcWidth = pOS2bmp->cx - nXsrc;
|
---|
523 | }
|
---|
524 | if(nYsrc + nSrcHeight > pOS2bmp->cy) {
|
---|
525 | nSrcHeight = pOS2bmp->cy - nYsrc;
|
---|
526 | }
|
---|
527 | #endif
|
---|
528 |
|
---|
529 | //target rectangle is inclusive-inclusive
|
---|
530 | point[2].x = nXsrc;
|
---|
531 | point[2].y = pOS2bmp->cy - nYsrc - nSrcHeight;
|
---|
532 | point[3].x = nXsrc + nSrcWidth;
|
---|
533 | point[3].y = pOS2bmp->cy - nYsrc;
|
---|
534 |
|
---|
535 | dprintf(("DIBSection::BitBlt (%d,%d)(%d,%d) from (%d,%d)(%d,%d) dim (%d,%d)(%d,%d)", point[0].x, point[0].y,
|
---|
536 | point[1].x, point[1].y, point[2].x, point[2].y, point[3].x, point[3].y,
|
---|
537 | nDestWidth, nDestHeight, nSrcWidth, nSrcHeight));
|
---|
538 |
|
---|
539 | #ifdef INVERT
|
---|
540 | oldyinversion = GpiQueryYInversion(hps);
|
---|
541 | if(oldyinversion != 0) {
|
---|
542 | GpiEnableYInversion(hps, 0);
|
---|
543 | fRestoryYInversion = TRUE;
|
---|
544 | }
|
---|
545 | #endif
|
---|
546 |
|
---|
547 | #ifdef DEBUG
|
---|
548 | RECTL rcltemp;
|
---|
549 | GreGetDCOrigin(hps, (PPOINTL)&rcltemp);
|
---|
550 | dprintf(("origin (%d,%d) yinv %d", rcltemp.xLeft, rcltemp.yBottom, oldyinversion));
|
---|
551 | #endif
|
---|
552 |
|
---|
553 | if(fFlip & FLIP_HOR)
|
---|
554 | {
|
---|
555 | ULONG x;
|
---|
556 | x = point[0].x;
|
---|
557 | point[0].x = point[1].x;
|
---|
558 | point[1].x = x;
|
---|
559 | }
|
---|
560 |
|
---|
561 | ULONG os2mode, winmode;
|
---|
562 |
|
---|
563 | os2mode = BBO_OR;
|
---|
564 | winmode = GetStretchBltMode(hdcDest);
|
---|
565 | switch(winmode) {
|
---|
566 | case BLACKONWHITE_W:
|
---|
567 | os2mode = BBO_AND;
|
---|
568 | break;
|
---|
569 | case WHITEONBLACK_W:
|
---|
570 | case HALFTONE_W: //TODO:
|
---|
571 | os2mode = BBO_OR;
|
---|
572 | break;
|
---|
573 | case COLORONCOLOR_W:
|
---|
574 | os2mode = BBO_IGNORE;
|
---|
575 | break;
|
---|
576 | }
|
---|
577 | if(fFlip & FLIP_VERT) {
|
---|
578 | //manually reverse bitmap data
|
---|
579 | char *src = bmpBits + (pOS2bmp->cy-1)*dibinfo.dsBm.bmWidthBytes;
|
---|
580 | char *dst = bmpBitsDblBuffer;
|
---|
581 | for(int i=0;i<pOS2bmp->cy;i++) {
|
---|
582 | memcpy(dst, src, dibinfo.dsBm.bmWidthBytes);
|
---|
583 | dst += dibinfo.dsBm.bmWidthBytes;
|
---|
584 | src -= dibinfo.dsBm.bmWidthBytes;
|
---|
585 | }
|
---|
586 | bitmapBits = bmpBitsDblBuffer;
|
---|
587 | }
|
---|
588 | else bitmapBits = bmpBits;
|
---|
589 |
|
---|
590 | //Translate ROP
|
---|
591 | Rop = Rop >> 16;
|
---|
592 |
|
---|
593 | //SvL: Optimize this.. (don't convert entire bitmap if only a part will be blitted to the dc)
|
---|
594 | if(dibinfo.dsBitfields[1] == 0x3E0) {//RGB 555?
|
---|
595 | dprintf(("DIBSection::BitBlt; convert rgb 555 to 565 (old y inv. = %d)", oldyinversion));
|
---|
596 |
|
---|
597 | if(bmpBitsDblBuffer == NULL)
|
---|
598 | DebugInt3();
|
---|
599 |
|
---|
600 | // PH 2000/10/01 - Fix for Beyond Compare 1.9d
|
---|
601 | // Note: according to documentation, cmImage can be zero for
|
---|
602 | // RGB- / non-compressed bitmaps.
|
---|
603 | int iLength = pOS2bmp->cbImage;
|
---|
604 | if (iLength == 0)
|
---|
605 | iLength = pOS2bmp->cx * pOS2bmp->cy * (pOS2bmp->cBitCount >> 3);
|
---|
606 |
|
---|
607 | if (iLength > 0)
|
---|
608 | {
|
---|
609 | if(CPUFeatures & CPUID_MMX)
|
---|
610 | RGB555to565MMX((WORD *)bmpBitsDblBuffer, (WORD *)bitmapBits, iLength/sizeof(WORD));
|
---|
611 | else RGB555to565((WORD *)bmpBitsDblBuffer, (WORD *)bitmapBits, iLength/sizeof(WORD));
|
---|
612 | }
|
---|
613 | else
|
---|
614 | {
|
---|
615 | dprintf(("GDI32: DIBSect::BitBlt: WARNING! zero-length bitmap! %08xh", pOS2bmp));
|
---|
616 | }
|
---|
617 |
|
---|
618 |
|
---|
619 | rc = GpiDrawBits(hps, bmpBitsDblBuffer, pOS2bmp, 4, &point[0], Rop, os2mode);
|
---|
620 | }
|
---|
621 | else {
|
---|
622 | rc = GpiDrawBits(hps, bitmapBits, pOS2bmp, 4, &point[0], Rop, os2mode);
|
---|
623 | }
|
---|
624 | if(rc == GPI_OK) {
|
---|
625 | DIBSection *destdib = DIBSection::findHDC(hdcDest);
|
---|
626 | if(destdib) {
|
---|
627 | destdib->sync(hps, nYdest, nDestHeight, FALSE);
|
---|
628 | }
|
---|
629 | #ifdef INVERT
|
---|
630 | //restore old y inversion height
|
---|
631 | if(fRestoryYInversion) GpiEnableYInversion(hps, oldyinversion);
|
---|
632 | #endif
|
---|
633 | SetLastError(ERROR_SUCCESS_W);
|
---|
634 |
|
---|
635 | return(TRUE);
|
---|
636 | }
|
---|
637 | #ifdef INVERT
|
---|
638 | if(fRestoryYInversion) GpiEnableYInversion(hps, oldyinversion);
|
---|
639 | #endif
|
---|
640 |
|
---|
641 | dprintf(("DIBSection::BitBlt %X (%d,%d) (%d,%d) to (%d,%d) (%d,%d) returned %d\n", hps, point[0].x, point[0].y, point[1].x, point[1].y, point[2].x, point[2].y, point[3].x, point[3].y, rc));
|
---|
642 | dprintf(("WinGetLastError returned %X\n", WinGetLastError(WinQueryAnchorBlock(hwndDest)) & 0xFFFF));
|
---|
643 | return(FALSE);
|
---|
644 | }
|
---|
645 | //******************************************************************************
|
---|
646 | //******************************************************************************
|
---|
647 | void DIBSection::sync(HDC hdc, DWORD nYdest, DWORD nDestHeight, BOOL orgYInversion)
|
---|
648 | {
|
---|
649 | APIRET rc;
|
---|
650 | char *destBuf;
|
---|
651 |
|
---|
652 | dprintf(("Sync destination dibsection %x (%x) (%d,%d) flip %d", handle, hdc, nYdest, nDestHeight, fFlip));
|
---|
653 |
|
---|
654 | BITMAPINFO2 *tmphdr = (BITMAPINFO2 *)malloc(os2bmphdrsize);
|
---|
655 | memcpy(tmphdr, pOS2bmp, os2bmphdrsize);
|
---|
656 |
|
---|
657 | #ifdef INVERT
|
---|
658 | int oldyinversion = 0;
|
---|
659 | if(orgYInversion == TRUE) {
|
---|
660 | oldyinversion = GpiQueryYInversion(hdc);
|
---|
661 | dprintf(("Sync destination dibsection: hdc y inversion = %d", oldyinversion));
|
---|
662 | if(oldyinversion != 0) {
|
---|
663 | GpiEnableYInversion(hdc, 0);
|
---|
664 | }
|
---|
665 | }
|
---|
666 | #endif
|
---|
667 |
|
---|
668 | if(fFlip & FLIP_VERT) {
|
---|
669 | destBuf = bmpBitsDblBuffer + nYdest*dibinfo.dsBm.bmWidthBytes;
|
---|
670 |
|
---|
671 | //SvL: cbImage can be too small for compressed images; GpiQueryBitmapBits
|
---|
672 | // will fail in that case (CoolEdit 2000). Perhaps because the returned
|
---|
673 | // compressed image is larger than the original.
|
---|
674 | // Use uncompressed size instead
|
---|
675 | // NOTE: The correct size will be returned by GpiQueryBitmapBits
|
---|
676 | tmphdr->cbImage = dibinfo.dsBm.bmHeight*dibinfo.dsBm.bmWidthBytes;
|
---|
677 |
|
---|
678 | rc = GpiQueryBitmapBits(hdc, nYdest, nDestHeight, destBuf,
|
---|
679 | tmphdr);
|
---|
680 | if(rc == GPI_ALTERROR) {
|
---|
681 | dprintf(("ERROR: GpiQueryBitmapBits failed with %x", WinGetLastError(0)));
|
---|
682 | }
|
---|
683 |
|
---|
684 | //manually reverse bitmap data
|
---|
685 | char *src = destBuf;
|
---|
686 | char *dst = GetDIBObject() + (nYdest+nDestHeight-1)*dibinfo.dsBm.bmWidthBytes;
|
---|
687 | for(int i=0;i<nDestHeight;i++) {
|
---|
688 | memcpy(dst, src, dibinfo.dsBm.bmWidthBytes);
|
---|
689 | dst -= dibinfo.dsBm.bmWidthBytes;
|
---|
690 | src += dibinfo.dsBm.bmWidthBytes;
|
---|
691 | }
|
---|
692 | }
|
---|
693 | else {
|
---|
694 | //SvL: cbImage can be too small for compressed images; GpiQueryBitmapBits
|
---|
695 | // will fail in that case (CoolEdit 2000). Perhaps because the returned
|
---|
696 | // compressed image is larger than the original.
|
---|
697 | // Use uncompressed size instead
|
---|
698 | // NOTE: The correct size will be returned by GpiQueryBitmapBits
|
---|
699 | tmphdr->cbImage = dibinfo.dsBm.bmHeight*dibinfo.dsBm.bmWidthBytes;
|
---|
700 |
|
---|
701 | destBuf = GetDIBObject() + nYdest*dibinfo.dsBm.bmWidthBytes;
|
---|
702 | rc = GpiQueryBitmapBits(hdc, nYdest, nDestHeight, destBuf,
|
---|
703 | tmphdr);
|
---|
704 | if(rc == GPI_ALTERROR) {
|
---|
705 | dprintf(("ERROR: GpiQueryBitmapBits failed with %x", WinGetLastError(0)));
|
---|
706 | }
|
---|
707 | #ifdef DEBUG_PALETTE
|
---|
708 | if(rc != GPI_ALTERROR && tmphdr->cBitCount <= 8) {
|
---|
709 | for(int i=0;i<(1<<tmphdr->cBitCount);i++)
|
---|
710 | {
|
---|
711 | dprintf2(("Index %d : 0x%08X\n",i, *((ULONG*)(&tmphdr->argbColor[i])) ));
|
---|
712 | }
|
---|
713 | }
|
---|
714 | #endif
|
---|
715 | }
|
---|
716 | memcpy(pOS2bmp, tmphdr, os2bmphdrsize);
|
---|
717 |
|
---|
718 | if(dibinfo.dsBitfields[1] == 0x3E0) {//RGB 555?
|
---|
719 | dprintf(("DIBSection::sync: convert RGB 565 to RGB 555"));
|
---|
720 |
|
---|
721 | destBuf = GetDIBObject() + nYdest*dibinfo.dsBm.bmWidthBytes;
|
---|
722 |
|
---|
723 | if(CPUFeatures & CPUID_MMX) {
|
---|
724 | RGB565to555MMX((WORD *)destBuf, (WORD *)destBuf, (nDestHeight*dibinfo.dsBm.bmWidthBytes)/sizeof(WORD));
|
---|
725 | }
|
---|
726 | else RGB565to555((WORD *)destBuf, (WORD *)destBuf, (nDestHeight*dibinfo.dsBm.bmWidthBytes)/sizeof(WORD));
|
---|
727 | }
|
---|
728 |
|
---|
729 | free(tmphdr);
|
---|
730 | if(rc != nDestHeight) {
|
---|
731 | DebugInt3();
|
---|
732 | }
|
---|
733 |
|
---|
734 | #ifdef INVERT
|
---|
735 | if(oldyinversion) GpiEnableYInversion(hdc, oldyinversion);
|
---|
736 | #endif
|
---|
737 |
|
---|
738 | }
|
---|
739 | //******************************************************************************
|
---|
740 | //manual sync if no stretching and bpp is the same
|
---|
741 | //WARNING: this also assumes the colortables are the same
|
---|
742 | //******************************************************************************
|
---|
743 | void DIBSection::sync(DWORD xDst, DWORD yDst, DWORD widthDst, DWORD heightDst, PVOID bits)
|
---|
744 | {
|
---|
745 | char *srcbuf, *destbuf;
|
---|
746 | int linesize;
|
---|
747 |
|
---|
748 | srcbuf = (char *)bits + dibinfo.dsBm.bmWidthBytes*yDst +
|
---|
749 | (xDst*dibinfo.dsBm.bmWidthBytes)/pOS2bmp->cx;
|
---|
750 | destbuf = (char *)GetDIBObject() + dibinfo.dsBm.bmWidthBytes*yDst +
|
---|
751 | (xDst*dibinfo.dsBm.bmWidthBytes)/pOS2bmp->cx;
|
---|
752 | linesize = (widthDst*dibinfo.dsBm.bmWidthBytes)/pOS2bmp->cx;
|
---|
753 | for(int i=0;i<heightDst;i++) {
|
---|
754 | memcpy(destbuf, srcbuf, linesize);
|
---|
755 | destbuf += dibinfo.dsBm.bmWidthBytes;
|
---|
756 | srcbuf += linesize;
|
---|
757 | }
|
---|
758 | }
|
---|
759 | //******************************************************************************
|
---|
760 | //******************************************************************************
|
---|
761 | void DIBSection::SelectDIBObject(HDC hdc)
|
---|
762 | {
|
---|
763 | this->hdc = hdc;
|
---|
764 | hwndParent = WindowFromDC(hdc);
|
---|
765 | dprintf(("SelectDIBObject %x into %x hwndParent = %x", handle, hdc, hwndParent));
|
---|
766 | }
|
---|
767 | //******************************************************************************
|
---|
768 | //******************************************************************************
|
---|
769 | DIBSection *DIBSection::findObj(HANDLE handle)
|
---|
770 | {
|
---|
771 | // PH 2001-08-18 shortcut for performance optimization
|
---|
772 | if (!section)
|
---|
773 | return NULL;
|
---|
774 |
|
---|
775 | DIBSection *dsect = section;
|
---|
776 | dibMutex.enter();
|
---|
777 |
|
---|
778 | do
|
---|
779 | {
|
---|
780 | if(dsect->handle == handle)
|
---|
781 | {
|
---|
782 | dibMutex.leave();
|
---|
783 | return(dsect);
|
---|
784 | }
|
---|
785 | dsect = dsect->next;
|
---|
786 | }
|
---|
787 | while(dsect);
|
---|
788 |
|
---|
789 | dibMutex.leave();
|
---|
790 | return(NULL);
|
---|
791 | }
|
---|
792 | //******************************************************************************
|
---|
793 | //A bitmap can only be selected into one DC, so this works.
|
---|
794 | //******************************************************************************
|
---|
795 | DIBSection *DIBSection::findHDC(HDC hdc)
|
---|
796 | {
|
---|
797 | // PH 2001-08-18 shortcut for performance optimization
|
---|
798 | if (!section)
|
---|
799 | return NULL;
|
---|
800 |
|
---|
801 | DIBSection *dsect = section;
|
---|
802 |
|
---|
803 | do
|
---|
804 | {
|
---|
805 | if(dsect->hdc == hdc)
|
---|
806 | {
|
---|
807 | return(dsect);
|
---|
808 | }
|
---|
809 | dsect = dsect->next;
|
---|
810 | }
|
---|
811 | while(dsect);
|
---|
812 |
|
---|
813 | return(NULL);
|
---|
814 | }
|
---|
815 | //******************************************************************************
|
---|
816 | //******************************************************************************
|
---|
817 | void DIBSection::deleteSection(HANDLE handle)
|
---|
818 | {
|
---|
819 | DIBSection *dsect = findObj(handle);
|
---|
820 |
|
---|
821 | if(dsect)
|
---|
822 | delete dsect;
|
---|
823 | }
|
---|
824 | //******************************************************************************
|
---|
825 | //******************************************************************************
|
---|
826 | int DIBSection::GetDIBSection(int iSize, void *lpBuffer)
|
---|
827 | {
|
---|
828 | DIBSECTION *pDIBSection = (DIBSECTION *)lpBuffer;
|
---|
829 | LPBITMAP_W dsBm = (LPBITMAP_W)lpBuffer;
|
---|
830 |
|
---|
831 | dprintf2(("GetDIBSection %x %d %x", handle, iSize, lpBuffer));
|
---|
832 | if(iSize == sizeof(DIBSECTION))
|
---|
833 | {
|
---|
834 | memcpy(pDIBSection, &dibinfo, sizeof(dibinfo));
|
---|
835 | return sizeof(DIBSECTION);
|
---|
836 | }
|
---|
837 | else
|
---|
838 | if(iSize == sizeof(BITMAP_W))
|
---|
839 | {
|
---|
840 | memcpy(dsBm, &dibinfo.dsBm, sizeof(dibinfo.dsBm));
|
---|
841 | return sizeof(BITMAP_W);
|
---|
842 | }
|
---|
843 | return 0;
|
---|
844 |
|
---|
845 | }
|
---|
846 | //******************************************************************************
|
---|
847 | //******************************************************************************
|
---|
848 | int DIBSection::GetBitCount()
|
---|
849 | {
|
---|
850 | if(pOS2bmp == NULL)
|
---|
851 | return 0;
|
---|
852 | else
|
---|
853 | return pOS2bmp->cBitCount;
|
---|
854 | }
|
---|
855 | //******************************************************************************
|
---|
856 | //******************************************************************************
|
---|
857 | int DIBSection::GetHeight()
|
---|
858 | {
|
---|
859 | if(pOS2bmp == NULL)
|
---|
860 | return 0;
|
---|
861 | else
|
---|
862 | return pOS2bmp->cy;
|
---|
863 | }
|
---|
864 | //******************************************************************************
|
---|
865 | //******************************************************************************
|
---|
866 | int DIBSection::GetWidth()
|
---|
867 | {
|
---|
868 | if(pOS2bmp == NULL)
|
---|
869 | return 0;
|
---|
870 | else
|
---|
871 | return pOS2bmp->cx;
|
---|
872 | }
|
---|
873 | //******************************************************************************
|
---|
874 | //******************************************************************************
|
---|
875 | DIBSection *DIBSection::section = NULL;
|
---|