source: trunk/src/gdi32/dibsect.cpp@ 3418

Last change on this file since 3418 was 3418, checked in by sandervl, 25 years ago

dib section fixes

File size: 19.2 KB
Line 
1/* $Id: dibsect.cpp,v 1.28 2000-04-18 11:11:52 sandervl Exp $ */
2
3/*
4 * GDI32 DIB sections
5 *
6 * Copyright 1998 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 <win32wnd.h>
28#include <cpuhlp.h>
29#include "oslibgpi.h"
30#include "rgbcvt.h"
31
32#define DBG_LOCALLOG DBG_dibsect
33#include "dbglocal.h"
34
35static VMutex dibMutex;
36
37//******************************************************************************
38//******************************************************************************
39DIBSection::DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD hSection, DWORD dwOffset, DWORD handle, int fFlip)
40 : bmpBits(NULL), pOS2bmp(NULL), next(NULL), bmpBitsRGB565(NULL)
41{
42 bmpsize = pbmi->biWidth;
43 /* @@@PH 98/06/07 -- high-color bitmaps don't have palette */
44
45 this->fFlip = fFlip;
46 os2bmphdrsize = sizeof(BITMAPINFO2);
47
48 switch(pbmi->biBitCount)
49 {
50 case 1:
51 bmpsize = ((bmpsize + 31) & ~31) / 8;
52 os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);
53 break;
54 case 4:
55 bmpsize = ((bmpsize + 7) & ~7) / 2;
56 os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);
57 break;
58 case 8:
59 os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);
60 bmpsize = (bmpsize + 3) & ~3;
61 break;
62 case 16:
63 bmpsize *= 2;
64 bmpsize = (bmpsize + 3) & ~3;
65 break;
66 case 24:
67 bmpsize *= 3;
68 bmpsize = (bmpsize + 3) & ~3;
69 break;
70 case 32:
71 bmpsize *= 4;
72 break;
73 default:
74 dprintf(("Unsupported nr of bits %d", pbmi->biBitCount));
75 DebugInt3();
76 break;
77 }
78
79 this->hSection = hSection;
80 if(hSection) {
81 bmpBits = (char *)MapViewOfFile(hSection, FILE_MAP_ALL_ACCESS_W, 0, dwOffset, bmpsize*pbmi->biHeight);
82 if(!bmpBits) {
83 dprintf(("Dibsection: mapViewOfFile %x failed!", hSection));
84 DebugInt3();
85 }
86 }
87 if(!bmpBits) {
88 DosAllocMem((PPVOID)&bmpBits, bmpsize*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT);
89 }
90 memset(bmpBits, 0, bmpsize*pbmi->biHeight);
91
92 pOS2bmp = (BITMAPINFO2 *)malloc(os2bmphdrsize);
93
94 memset(pOS2bmp, /* set header + palette entries to zero */
95 0,
96 os2bmphdrsize);
97
98 pOS2bmp->cbFix = sizeof(BITMAPINFO2) - sizeof(RGB2);
99 pOS2bmp->cx = pbmi->biWidth;
100 pOS2bmp->cy = pbmi->biHeight;
101 pOS2bmp->cPlanes = pbmi->biPlanes;
102 pOS2bmp->cBitCount = pbmi->biBitCount;
103 pOS2bmp->ulCompression = pbmi->biCompression;
104 //SvL: Ignore BI_BITFIELDS type (GpiDrawBits fails otherwise)
105 if(pOS2bmp->ulCompression == BI_BITFIELDS) {
106 pOS2bmp->ulCompression = 0;
107 }
108 pOS2bmp->cbImage = pbmi->biSizeImage;
109 dprintf(("handle %x", handle));
110 dprintf(("pOS2bmp->cx %d\n", pOS2bmp->cx));
111 dprintf(("pOS2bmp->cy %d\n", pOS2bmp->cy));
112 dprintf(("pOS2bmp->cPlanes %d\n", pOS2bmp->cPlanes));
113 dprintf(("pOS2bmp->cBitCount %d\n", pOS2bmp->cBitCount));
114 dprintf(("pOS2bmp->ulCompression %d\n", pOS2bmp->ulCompression));
115 dprintf(("pOS2bmp->cbImage %d\n", pOS2bmp->cbImage));
116 dprintf(("Bits at %x, size %d",bmpBits, bmpsize*pbmi->biHeight));
117
118 // clear DIBSECTION structure
119 memset(&dibinfo, 0, sizeof(dibinfo));
120
121 // copy BITMAPINFOHEADER data into DIBSECTION structure
122 memcpy(&dibinfo.dsBmih, pbmi, sizeof(*pbmi));
123 dibinfo.dsBm.bmType = 0;
124 dibinfo.dsBm.bmWidth = pbmi->biWidth;
125 dibinfo.dsBm.bmHeight = pbmi->biHeight;
126 dibinfo.dsBm.bmWidthBytes= bmpsize;
127 dibinfo.dsBm.bmPlanes = pbmi->biPlanes;
128 dibinfo.dsBm.bmBitsPixel = pbmi->biBitCount;
129 dibinfo.dsBm.bmBits = bmpBits;
130
131 dibinfo.dshSection = handle;
132 dibinfo.dsOffset = 0; // TODO: put the correct value here (if createdibsection with file handle)
133
134 if(iUsage == DIB_PAL_COLORS || pbmi->biBitCount <= 8)
135 {
136 dibinfo.dsBitfields[0] = dibinfo.dsBitfields[1] = dibinfo.dsBitfields[2] = 0;
137 }
138 else {
139 switch(pbmi->biBitCount)
140 {
141 case 16:
142 dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS) ? *(DWORD *)pColors : 0x7c00;
143 dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS) ? *((DWORD *)pColors + 1) : 0x03e0;
144 dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS) ? *((DWORD *)pColors + 2) : 0x001f;
145
146 //double buffer for rgb 555 dib sections (for conversion)
147 if(dibinfo.dsBitfields[1] == 0x03e0) {
148 DosAllocMem((PPVOID)&bmpBitsRGB565, bmpsize*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT);
149 }
150 break;
151
152 case 24:
153 dibinfo.dsBitfields[0] = 0xff;
154 dibinfo.dsBitfields[1] = 0xff00;
155 dibinfo.dsBitfields[2] = 0xff0000;
156 break;
157
158 case 32:
159 dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS) ? *(DWORD *)pColors : 0xff;
160 dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS) ? *((DWORD *)pColors + 1) : 0xff00;
161 dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS) ? *((DWORD *)pColors + 2) : 0xff0000;
162 if(dibinfo.dsBitfields[0] != 0xff && dibinfo.dsBitfields[1] != 0xff00 && dibinfo.dsBitfields[2] != 0xff0000) {
163 dprintf(("DIBSection: unsupported bitfields for 32 bits bitmap!!"));
164 }
165 break;
166 }
167 dprintf(("BI_BITFIELDS %x %x %x", dibinfo.dsBitfields[0], dibinfo.dsBitfields[1], dibinfo.dsBitfields[2]));
168 }
169
170 this->handle = handle;
171 this->iUsage = iUsage;
172
173 dibMutex.enter();
174 if(section == NULL)
175 {
176 dprintf(("section was NULL\n"));
177 section = this;
178 }
179 else
180 {
181 DIBSection *dsect = section;
182 dprintf2(("Increment section starting at %08X\n",dsect));
183
184 /* @@@PH 98/07/11 fix for dsect->next == NULL */
185 while ( (dsect->next != this) &&
186 (dsect->next != NULL) )
187 {
188 dprintf2(("Increment section to %08X\n",dsect->next));
189 dsect = dsect->next;
190 }
191 dsect->next = this;
192 }
193 dibMutex.leave();
194}
195//******************************************************************************
196//******************************************************************************
197DIBSection::~DIBSection()
198{
199 dprintf(("Delete DIBSection %x", handle));
200
201 if(hSection) {
202 UnmapViewOfFile(bmpBits);
203 }
204 else
205 if(bmpBits)
206 DosFreeMem(bmpBits);
207
208 if(bmpBitsRGB565)
209 DosFreeMem(bmpBitsRGB565);
210
211 if(pOS2bmp)
212 free(pOS2bmp);
213
214 dibMutex.enter();
215 if(section == this)
216 {
217 section = this->next;
218 }
219 else
220 {
221 DIBSection *dsect = section;
222
223 while(dsect->next != this)
224 {
225 dsect = dsect->next;
226 }
227 dsect->next = this->next;
228 }
229 dibMutex.leave();
230}
231//******************************************************************************
232//******************************************************************************
233int DIBSection::SetDIBits(HDC hdc, HBITMAP hbitmap, UINT startscan, UINT
234 lines, const VOID *bits, BITMAPINFOHEADER_W *pbmi,
235 UINT coloruse)
236{
237 lines = (int)lines >= 0 ? (int)lines : (int)-lines;
238 int palsize=0;
239
240 bmpsize = pbmi->biWidth;
241 os2bmphdrsize = sizeof(BITMAPINFO2);
242
243 switch(pbmi->biBitCount)
244 {
245 case 1:
246 bmpsize = ((bmpsize + 31) & ~31) / 8;
247 palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
248 os2bmphdrsize += palsize;
249 break;
250 case 4:
251 bmpsize = ((bmpsize + 7) & ~7) / 2;
252 palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
253 os2bmphdrsize += palsize;
254 break;
255 case 8:
256 palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
257 os2bmphdrsize += palsize;
258 bmpsize = (bmpsize + 3) & ~3;
259 break;
260 case 16:
261 bmpsize *= 2;
262 bmpsize = (bmpsize + 3) & ~3;
263 break;
264 case 24:
265 bmpsize *= 3;
266 bmpsize = (bmpsize + 3) & ~3;
267 break;
268 case 32:
269 bmpsize *= 4;
270 break;
271 }
272
273 //SvL: TODO: Correct??
274 if(!hSection && pOS2bmp->cx != pbmi->biWidth && pOS2bmp->cy != pbmi->biHeight &&
275 pOS2bmp->cBitCount != pbmi->biBitCount)
276 {
277 char *oldbits = bmpBits;
278 int oldsize = dibinfo.dsBm.bmWidthBytes * dibinfo.dsBm.bmHeight;
279
280 DosAllocMem((PPVOID)&bmpBits, bmpsize*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT);
281 memcpy(bmpBits, oldbits, min(oldsize, bmpsize*pbmi->biHeight));
282 DosFreeMem(oldbits);
283 }
284 pOS2bmp = (BITMAPINFO2 *)realloc(pOS2bmp, os2bmphdrsize);
285 pOS2bmp->cbFix = sizeof(BITMAPINFO2) - sizeof(RGB2);
286 pOS2bmp->cx = pbmi->biWidth;
287 pOS2bmp->cy = pbmi->biHeight;
288 pOS2bmp->cPlanes = pbmi->biPlanes;
289 pOS2bmp->cBitCount = pbmi->biBitCount;
290 pOS2bmp->ulCompression = pbmi->biCompression;
291 pOS2bmp->cbImage = pbmi->biSizeImage;
292
293 // clear DIBSECTION structure
294 memset(&dibinfo, 0, sizeof(dibinfo));
295
296 // copy BITMAPINFOHEADER data into DIBSECTION structure
297 memcpy(&dibinfo.dsBmih, pbmi, sizeof(*pbmi));
298 dibinfo.dsBm.bmType = 0;
299 dibinfo.dsBm.bmWidth = pbmi->biWidth;
300 dibinfo.dsBm.bmHeight = pbmi->biHeight;
301 dibinfo.dsBm.bmWidthBytes= bmpsize;
302 dibinfo.dsBm.bmPlanes = pbmi->biPlanes;
303 dibinfo.dsBm.bmBitsPixel = pbmi->biBitCount;
304 dibinfo.dsBm.bmBits = bmpBits;
305
306 dibinfo.dshSection = hSection;
307 dibinfo.dsOffset = 0; // TODO: put the correct value here (if createdibsection with file handle)
308
309 if(coloruse == DIB_PAL_COLORS || pbmi->biBitCount <= 8)
310 {
311 dibinfo.dsBitfields[0] = dibinfo.dsBitfields[1] = dibinfo.dsBitfields[2] = 0;
312 }
313 else {
314 char *pColors = (char *)pbmi + 1;
315
316 switch(pbmi->biBitCount)
317 {
318 case 16:
319 dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS) ? *(DWORD *)pColors : 0x7c00;
320 dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS) ? *((DWORD *)pColors + 1) : 0x03e0;
321 dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS) ? *((DWORD *)pColors + 2) : 0x001f;
322 break;
323
324 case 24:
325 dibinfo.dsBitfields[0] = 0xff;
326 dibinfo.dsBitfields[1] = 0xff00;
327 dibinfo.dsBitfields[2] = 0xff0000;
328 break;
329
330 case 32:
331 dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS) ? *(DWORD *)pColors : 0xff;
332 dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS) ? *((DWORD *)pColors + 1) : 0xff00;
333 dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS) ? *((DWORD *)pColors + 2) : 0xff0000;
334 if(dibinfo.dsBitfields[0] != 0xff && dibinfo.dsBitfields[1] != 0xff00 && dibinfo.dsBitfields[2] != 0xff0000) {
335 dprintf(("DIBSection: unsupported bitfields for 32 bits bitmap!!"));
336 }
337 break;
338 }
339 dprintf(("BI_BITFIELDS %x %x %x", dibinfo.dsBitfields[0], dibinfo.dsBitfields[1], dibinfo.dsBitfields[2]));
340 }
341
342 dprintf(("DIBSection::SetDIBits (%d,%d), %d %d", pbmi->biWidth, pbmi->biHeight, pbmi->biBitCount, pbmi->biCompression));
343 if(palsize)
344 memcpy(pOS2bmp->argbColor, (char *)pbmi + 1 , palsize);
345
346 if(bits)
347 {
348 int size = bmpsize*lines;
349 memcpy(bmpBits+bmpsize*startscan, bits, size);
350 }
351 return(lines);
352}
353//******************************************************************************
354//******************************************************************************
355int DIBSection::SetDIBColorTable(int startIdx, int cEntries, RGBQUAD *rgb)
356{
357 int i;
358
359 if(startIdx + cEntries > (1 << pOS2bmp->cBitCount))
360 {
361 dprintf(("DIBSection::SetDIBColorTable, invalid nr of entries %d %d\n", startIdx, cEntries));
362 return(0);
363 }
364
365 memcpy(&pOS2bmp->argbColor[startIdx], rgb, cEntries*sizeof(RGB2));
366
367 for(i=startIdx;i<cEntries;i++)
368 {
369 pOS2bmp->argbColor[i].fcOptions = 0;
370 dprintf2(("Index %d : 0x%08X\n",i, *((ULONG*)(&pOS2bmp->argbColor[i])) ));
371 }
372
373 return(cEntries);
374}
375//******************************************************************************
376//******************************************************************************
377BOOL DIBSection::BitBlt(HDC hdcDest, int nXdest, int nYdest, int nDestWidth,
378 int nDestHeight, int nXsrc, int nYsrc,
379 int nSrcWidth, int nSrcHeight, DWORD Rop)
380{
381 HPS hps = (HPS)hdcDest;
382 POINTL point[4];
383 LONG rc, hdcHeight, hdcWidth;
384 PVOID bitmapBits = NULL;
385 int oldyinversion = 0;
386 BOOL fRestoryYInversion = FALSE, fFrameWindowDC = FALSE;
387 HWND hwndDest;
388
389 hwndDest = WindowFromDC(hdcDest);
390 //TODO: Test whether dc is for the client or frame window
391// if(hwndDest && IsOS2FrameWindowHandle(hwndDest)) {
392// fFrameWindowDC = TRUE;
393// }
394
395 dprintf(("DIBSection::BitBlt %x %X (hps %x) %x to(%d,%d)(%d,%d) from (%d,%d)(%d,%d) rop %x flip %x",
396 handle, hdcDest, hps, hwndDest, nXdest, nYdest, nDestWidth, nDestHeight,
397 nXsrc, nYsrc, nSrcWidth, nSrcHeight, Rop, fFlip));
398
399 if(hwndDest) {
400 RECT rect;
401
402 if(fFrameWindowDC) {
403 GetWindowRect(hwndDest, &rect);
404 }
405 else GetClientRect(hwndDest, &rect);
406 hdcHeight = rect.bottom - rect.top;
407 hdcWidth = rect.right - rect.left;
408 }
409 else {
410 hdcHeight = pOS2bmp->cy;
411 hdcWidth = pOS2bmp->cx;
412 }
413
414 //win32 coordinates are of the left top, OS/2 expects left bottom
415 //source rectangle is non-inclusive (top, right not included)
416 if(nXdest + nDestWidth > hdcWidth) {
417 nDestWidth = hdcWidth - nXdest;
418 }
419 if(nYdest + nDestHeight > hdcHeight) {
420 nDestHeight = hdcHeight - nYdest;
421 }
422 point[0].x = nXdest;
423 point[0].y = hdcHeight - nYdest - nDestHeight;
424 point[1].x = nXdest + nDestWidth;
425 point[1].y = hdcHeight - nYdest;
426
427 //target rectangle is inclusive-inclusive
428 if(nXsrc + nSrcWidth > pOS2bmp->cx) {
429 nSrcWidth = pOS2bmp->cx - nXsrc;
430 }
431 if(nYsrc + nSrcHeight > pOS2bmp->cy) {
432 nSrcHeight = pOS2bmp->cy - nYsrc;
433 }
434 point[2].x = nXsrc;
435 point[2].y = pOS2bmp->cy - nYsrc - nSrcHeight;
436 point[3].x = nXsrc + nSrcWidth - 1;
437 point[3].y = pOS2bmp->cy - nYsrc - 1;
438
439 oldyinversion = GpiQueryYInversion(hps);
440 if(fFlip & FLIP_VERT)
441 {
442 if(oldyinversion != hdcHeight-1) {
443 GpiEnableYInversion(hps, hdcHeight-1);
444 fRestoryYInversion = TRUE;
445 }
446 }
447 else
448 if(oldyinversion != 0) {
449 GpiEnableYInversion(hps, 0);
450 fRestoryYInversion = TRUE;
451 }
452
453 if(fFlip & FLIP_HOR)
454 {
455 ULONG x;
456 x = point[0].x;
457 point[0].x = point[1].x;
458 point[1].x = x;
459 }
460
461 //SvL: Optimize this.. (don't convert entire bitmap if only a part will be blitted to the dc)
462 if(dibinfo.dsBitfields[1] == 0x3E0) {//RGB 555?
463 dprintf(("DIBSection::BitBlt; convert rgb 555 to 565 (old y inv. = %d)", oldyinversion));
464
465 if(bmpBitsRGB565 == NULL)
466 DebugInt3();
467
468 if(CPUFeatures & CPUID_MMX) {
469 RGB555to565MMX((WORD *)bmpBitsRGB565, (WORD *)bmpBits, pOS2bmp->cbImage/sizeof(WORD));
470 }
471 else RGB555to565((WORD *)bmpBitsRGB565, (WORD *)bmpBits, pOS2bmp->cbImage/sizeof(WORD));
472 rc = GpiDrawBits(hps, bmpBitsRGB565, pOS2bmp, 4, &point[0], ROP_SRCCOPY, BBO_OR);
473 }
474 else rc = GpiDrawBits(hps, bmpBits, pOS2bmp, 4, &point[0], ROP_SRCCOPY, BBO_OR);
475
476 if(rc == GPI_OK) {
477 DIBSection *destdib = DIBSection::findHDC(hdcDest);
478 if(destdib) {
479 destdib->sync(hps, nYdest, nDestHeight);
480 }
481 //restore old y inversion height
482 if(fRestoryYInversion) GpiEnableYInversion(hps, oldyinversion);
483 return(TRUE);
484 }
485 if(fRestoryYInversion) GpiEnableYInversion(hps, oldyinversion);
486
487 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));
488 dprintf(("WinGetLastError returned %X\n", WinGetLastError(WinQueryAnchorBlock(hwndDest)) & 0xFFFF));
489 return(FALSE);
490}
491//******************************************************************************
492//******************************************************************************
493void DIBSection::sync(HDC hdc, DWORD nYdest, DWORD nDestHeight)
494{
495 APIRET rc;
496 char *destBuf;
497
498 dprintf(("Sync destination dibsection %x (%x)", handle, hdc));
499
500 //todo: rgb 565 to 555 conversion if bpp == 16
501 if(GetBitCount() == 16) {
502 dprintf(("WARNING: need to convert RGB 565 to RGB 555!!"));
503 }
504
505 BITMAPINFO2 *tmphdr = (BITMAPINFO2 *)malloc(os2bmphdrsize);
506 memcpy(tmphdr, pOS2bmp, os2bmphdrsize);
507 destBuf = GetDIBObject() + nYdest*dibinfo.dsBm.bmWidthBytes;
508 rc = GpiQueryBitmapBits(hdc, nYdest, nDestHeight, destBuf,
509 tmphdr);
510 free(tmphdr);
511 if(rc != nDestHeight) {
512 DebugInt3();
513 }
514}
515//******************************************************************************
516//******************************************************************************
517void DIBSection::SelectDIBObject(HDC hdc)
518{
519 this->hdc = hdc;
520 hwndParent = WindowFromDC(hdc);
521 dprintf(("SelectDIBObject %x into %x hwndParent = %x", handle, hdc, hwndParent));
522}
523//******************************************************************************
524//******************************************************************************
525DIBSection *DIBSection::find(DWORD handle)
526{
527 DIBSection *dsect = section;
528
529 dibMutex.enter();
530 while(dsect)
531 {
532 if(dsect->handle == handle)
533 {
534 dibMutex.leave();
535 return(dsect);
536 }
537 dsect = dsect->next;
538 }
539 dibMutex.leave();
540 return(NULL);
541}
542//******************************************************************************
543//A bitmap can only be selected into one DC, so this works.
544//******************************************************************************
545DIBSection *DIBSection::findHDC(HDC hdc)
546{
547 DIBSection *dsect = section;
548
549 while(dsect)
550 {
551 if(dsect->hdc == hdc)
552 {
553 return(dsect);
554 }
555 dsect = dsect->next;
556 }
557 return(NULL);
558}
559//******************************************************************************
560//******************************************************************************
561void DIBSection::deleteSection(DWORD handle)
562{
563 DIBSection *dsect = find(handle);
564
565 if(dsect)
566 delete dsect;
567
568}
569//******************************************************************************
570//******************************************************************************
571int DIBSection::GetDIBSection(int iSize, void *lpBuffer)
572{
573 DIBSECTION *pDIBSection = (DIBSECTION *)lpBuffer;
574 LPBITMAP_W dsBm = (LPBITMAP_W)lpBuffer;
575
576 dprintf2(("GetDIBSection %x %d %x", handle, iSize, lpBuffer));
577 if(iSize == sizeof(DIBSECTION))
578 {
579 memcpy(pDIBSection, &dibinfo, sizeof(dibinfo));
580 return sizeof(DIBSECTION);
581 }
582 else
583 if(iSize == sizeof(BITMAP_W))
584 {
585 memcpy(dsBm, &dibinfo.dsBm, sizeof(dibinfo.dsBm));
586 return sizeof(BITMAP_W);
587 }
588 return 0;
589
590}
591//******************************************************************************
592//******************************************************************************
593char DIBSection::GetBitCount()
594{
595 if(pOS2bmp == NULL)
596 return 0;
597 else
598 return pOS2bmp->cBitCount;
599}
600//******************************************************************************
601//******************************************************************************
602DIBSection *DIBSection::section = NULL;
Note: See TracBrowser for help on using the repository browser.