Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

707 lines
17 KiB

  1. #include <windows.h>
  2. #include <windowsx.h>
  3. #include <win32.h>
  4. #include "lockbm.h"
  5. //////////////////////////////////////////////////////////////////////////////
  6. //////////////////////////////////////////////////////////////////////////////
  7. #ifndef BI_BITFIELDS
  8. #define BI_BITFIELDS 3
  9. #endif
  10. #ifndef BI_BITMAP
  11. #define BI_BITMAP 0x4D544942 // 'BITM'
  12. #endif
  13. //////////////////////////////////////////////////////////////////////////////
  14. //////////////////////////////////////////////////////////////////////////////
  15. //
  16. // GDI!GDIInit2() GDI.403
  17. //
  18. // this GDI function does the following:
  19. //
  20. // GetSetBitmapHandle(hbm, 0) - will return global handle of bitmap
  21. //
  22. // GetSetBitmapHandle(hbm, h) - will set global handle to <h>
  23. //
  24. // GetSetBitmapHandle(hbm, -1) - will set global handle to NULL
  25. //
  26. static HANDLE (FAR PASCAL *GetSetBitmapHandle)(HBITMAP hbm, HANDLE h);
  27. //////////////////////////////////////////////////////////////////////////////
  28. //////////////////////////////////////////////////////////////////////////////
  29. #define muldiv(a,b,c) (UINT)(((DWORD)(UINT)(a) * (DWORD)(UINT)(b)) / (UINT)(c))
  30. //////////////////////////////////////////////////////////////////////////////
  31. //
  32. // CanLockBitmaps()
  33. //
  34. // determime if we can lock bitmaps on the current display device
  35. //
  36. //////////////////////////////////////////////////////////////////////////////
  37. BOOL FAR CanLockBitmaps(void)
  38. {
  39. #ifndef WIN32
  40. //its not safe to do this on NT. god only knows what gdi.403 is on future
  41. //nt platforms - the only thing we can be sure of is that it is NOT
  42. // GetSetBitmapHandle()
  43. UINT w;
  44. UINT rc;
  45. HDC hdc;
  46. BOOL f;
  47. static BOOL fCanLockBitmaps = -1;
  48. if (fCanLockBitmaps == -1)
  49. {
  50. w = (UINT)GetVersion();
  51. w = ((UINT)LOBYTE(w) << 8) | HIBYTE(w);
  52. hdc = GetDC(NULL);
  53. rc = GetDeviceCaps(hdc, RASTERCAPS);
  54. ReleaseDC(NULL, hdc);
  55. (FARPROC)GetSetBitmapHandle =
  56. GetProcAddress(GetModuleHandle(TEXT("GDI")),(LPCSTR)MAKEINTATOM(403));
  57. #ifdef WIN32
  58. // MAKEINTATOM returns a LPTSTR.
  59. // GetProcAddress wants LPCSTR - NOT Unicode. Hence we cast
  60. #endif
  61. //
  62. // assume we dont need this on windows 4.0?
  63. //
  64. // what about the DIBENG? it does DEVBITS and in win 4.0?
  65. //
  66. // if the display handles device bitmaps, dont do this either
  67. //
  68. f = GetProfileIntA("DrawDib", "Bitmaps", TRUE);
  69. #ifdef DEBUG
  70. fCanLockBitmaps = f && GetSetBitmapHandle != NULL;
  71. #else
  72. fCanLockBitmaps = f && /* (w < 0x0400) && */
  73. !(rc & RC_DEVBITS) &&
  74. GetSetBitmapHandle != NULL;
  75. #endif
  76. }
  77. return fCanLockBitmaps;
  78. #else
  79. return FALSE;
  80. #endif
  81. }
  82. //////////////////////////////////////////////////////////////////////////////
  83. //
  84. // LockBitmap
  85. //
  86. // return a pointer to the bitmap bits
  87. //
  88. //////////////////////////////////////////////////////////////////////////////
  89. LPVOID FAR LockBitmap(HBITMAP hbm)
  90. {
  91. return GetBitmap(hbm, NULL, 0);
  92. }
  93. //////////////////////////////////////////////////////////////////////////////
  94. //
  95. // GetBitmapDIB
  96. //
  97. //////////////////////////////////////////////////////////////////////////////
  98. LPVOID FAR GetBitmapDIB(LPBITMAPINFOHEADER lpbi, LPVOID lpBits, LPVOID p, int cb)
  99. {
  100. IBITMAP FAR *pbm;
  101. if (lpBits == NULL)
  102. lpBits = (LPBYTE)lpbi + (int)lpbi->biSize + lpbi->biClrUsed * sizeof(RGBQUAD);
  103. if (p == NULL || cb < sizeof(BITMAP))
  104. return lpBits;
  105. pbm = p;
  106. if (lpbi->biCompression == 0)
  107. {
  108. switch ((int)lpbi->biBitCount + (int)lpbi->biPlanes*256)
  109. {
  110. case 0x0101: pbm->bmType = BM_1BIT; break;
  111. case 0x0104: pbm->bmType = BM_4BIT; break;
  112. case 0x0108: pbm->bmType = BM_8BIT; break;
  113. case 0x0110: pbm->bmType = BM_16555; break;
  114. case 0x0118: pbm->bmType = BM_24BGR; break;
  115. case 0x0120: pbm->bmType = BM_32BGR; break;
  116. case 0x0401: pbm->bmType = BM_VGA; break;
  117. default: return NULL;
  118. }
  119. }
  120. else if (lpbi->biCompression == BI_BITFIELDS)
  121. {
  122. switch ((int)lpbi->biBitCount + (int)lpbi->biPlanes*256)
  123. {
  124. //!!! hack: realy should check the bit fields!
  125. case 0x0110: pbm->bmType = BM_16565; break;
  126. case 0x0118: pbm->bmType = BM_24RGB; break;
  127. case 0x0120: pbm->bmType = BM_32RGB; break;
  128. default: return NULL;
  129. }
  130. }
  131. else
  132. return NULL;
  133. pbm->bmWidth = (int)lpbi->biWidth;
  134. pbm->bmHeight = ((int)lpbi->biHeight > 0) ? (int)lpbi->biHeight : -(int)lpbi->biHeight;
  135. pbm->bmWidthBytes = (((int)lpbi->biBitCount * (int)lpbi->biWidth + 31)&~31)/8;
  136. pbm->bmPlanes = (BYTE)lpbi->biPlanes;
  137. pbm->bmBitsPixel = (BYTE)lpbi->biBitCount;
  138. pbm->bmBits = lpBits;
  139. if (cb > sizeof(BITMAP))
  140. {
  141. pbm->bmSegmentIndex = 0;
  142. pbm->bmScanSegment = pbm->bmHeight;
  143. pbm->bmFillBytes = 0;
  144. pbm->bmBitmapInfo = (long)lpbi;
  145. if ((long)lpbi->biHeight < 0)
  146. {
  147. pbm->bmNextScan = -pbm->bmWidthBytes;
  148. pbm->bmOffset = (long)pbm->bmWidthBytes * (pbm->bmHeight-1);
  149. }
  150. else
  151. {
  152. pbm->bmNextScan = pbm->bmWidthBytes;
  153. pbm->bmOffset = 0;
  154. }
  155. }
  156. return lpBits;
  157. }
  158. #if 0
  159. //////////////////////////////////////////////////////////////////////////////
  160. //////////////////////////////////////////////////////////////////////////////
  161. void FAR BitmapXY(IBITMAP FAR *pbm, int x, int y)
  162. {
  163. UINT t;
  164. if (pbm->bmFillBytes)
  165. {
  166. while (y-- > 0)
  167. {
  168. t = (UINT)(pbm->bmOffset & 0xFFFF0000);
  169. pbm->bmOffset += pbm->bmNextScan;
  170. if ((UINT)(pbm->bmOffset & 0xFFFF0000) != t)
  171. pbm->bmOffset += pbm->bmFillBytes;
  172. }
  173. }
  174. else
  175. {
  176. pbm->bmOffset += y * (long)pbm->bmNextScan;
  177. }
  178. pbm->bmOffset += x * pbm->bmBitsPixel / 8;
  179. }
  180. #endif
  181. //////////////////////////////////////////////////////////////////////////////
  182. //
  183. // GetDIBBitmap
  184. //
  185. //////////////////////////////////////////////////////////////////////////////
  186. /*
  187. * creates a DIB header for a bitmap, and returns a pointer to the bitmap
  188. * bits. This pointer is not used - it's checked against NULL, as if this
  189. * routine returned BOOL.
  190. *
  191. * On NT, you can't get the bitmap bits (wrong process) so we return 1 meaning
  192. * TRUE. You need to call SetBitmapBits to access the bits themselves.
  193. */
  194. LPVOID FAR GetDIBBitmap(HBITMAP hbm, LPBITMAPINFOHEADER lpbi)
  195. {
  196. UINT wType;
  197. BITMAP bm;
  198. UINT ScansPerSeg;
  199. UINT FillBytes;
  200. if (hbm)
  201. GetObject(hbm, sizeof(bm), &bm);
  202. wType = GetBitmapType();
  203. if (wType == 0)
  204. return NULL;
  205. lpbi->biSize = sizeof(BITMAPINFOHEADER);
  206. lpbi->biWidth = bm.bmWidth;
  207. lpbi->biHeight = bm.bmHeight;
  208. lpbi->biPlanes = bm.bmPlanes;
  209. lpbi->biBitCount = bm.bmBitsPixel;
  210. lpbi->biCompression = 0;
  211. lpbi->biSizeImage = (DWORD)(bm.bmWidthBytes * bm.bmPlanes) * (DWORD)bm.bmHeight;
  212. lpbi->biXPelsPerMeter = 0;
  213. lpbi->biYPelsPerMeter = 0;
  214. lpbi->biClrUsed = 0;
  215. lpbi->biClrImportant = 0;
  216. switch(wType & BM_TYPE)
  217. {
  218. case BM_VGA:
  219. break;
  220. case BM_1BIT:
  221. case BM_4BIT:
  222. case BM_8BIT:
  223. break;
  224. case BM_16555:
  225. break;
  226. case BM_24BGR:
  227. case BM_32BGR:
  228. break;
  229. case BM_16565:
  230. lpbi->biCompression = BI_BITFIELDS;
  231. ((LPDWORD)(lpbi+1))[0] = 0x00F800;
  232. ((LPDWORD)(lpbi+1))[1] = 0x0007E0;
  233. ((LPDWORD)(lpbi+1))[2] = 0x00001F;
  234. break;
  235. case BM_24RGB:
  236. case BM_32RGB:
  237. lpbi->biCompression = BI_BITFIELDS;
  238. ((LPDWORD)(lpbi+1))[0] = 0x0000FF;
  239. ((LPDWORD)(lpbi+1))[1] = 0x00FF00;
  240. ((LPDWORD)(lpbi+1))[2] = 0xFF0000;
  241. break;
  242. default:
  243. return NULL;
  244. }
  245. //
  246. // make sure WidthBytes is right, dont forget bitmaps are WORD aligned
  247. // and DIBs are DWORD aligned.
  248. //
  249. if (bm.bmWidthBytes != ((bm.bmWidth * bm.bmBitsPixel + 31) & ~31)/8)
  250. {
  251. if (lpbi->biCompression != 0)
  252. return NULL;
  253. lpbi->biCompression = BI_BITMAP;
  254. lpbi->biXPelsPerMeter = bm.bmWidthBytes;
  255. }
  256. if ((wType & BM_HUGE) && (lpbi->biSizeImage > 64*1024l))
  257. {
  258. if (lpbi->biCompression == BI_BITFIELDS)
  259. return NULL;
  260. lpbi->biCompression = BI_BITMAP;
  261. ScansPerSeg = muldiv(64,1024,bm.bmWidthBytes * bm.bmPlanes);
  262. FillBytes = (UINT)(64ul*1024 - bm.bmWidthBytes * bm.bmPlanes * ScansPerSeg);
  263. lpbi->biSizeImage += FillBytes * (bm.bmHeight / ScansPerSeg);
  264. lpbi->biXPelsPerMeter = bm.bmWidthBytes;
  265. lpbi->biYPelsPerMeter = FillBytes;
  266. }
  267. if (!(wType & BM_BOTTOMTOTOP))
  268. lpbi->biHeight = -bm.bmHeight;
  269. #ifdef WIN32
  270. return (LPVOID) TRUE;
  271. #else
  272. return LockBitmap(hbm);
  273. #endif
  274. }
  275. //////////////////////////////////////////////////////////////////////////////
  276. //
  277. // GetBitmap
  278. //
  279. //////////////////////////////////////////////////////////////////////////////
  280. LPVOID FAR GetBitmap(HBITMAP hbm, LPVOID p, int cb)
  281. {
  282. HANDLE h;
  283. DWORD dwSize;
  284. IBITMAP FAR *pbm;
  285. HDC hdc = NULL;
  286. HBITMAP hbmT;
  287. if (!CanLockBitmaps())
  288. return NULL;
  289. if (hbm == NULL)
  290. return NULL;
  291. h = GetSetBitmapHandle(hbm, 0);
  292. if (h == NULL)
  293. return NULL;
  294. pbm = (LPVOID)GlobalLock(h);
  295. if (IsBadReadPtr(pbm, sizeof(IBITMAP)))
  296. return NULL;
  297. //
  298. // see if it is realy a bitmap.
  299. //
  300. if (pbm->bmType != 0)
  301. return NULL;
  302. //
  303. // make sure the bmBits pointer is valid.
  304. //
  305. if (pbm->bmBits == NULL)
  306. {
  307. hdc = CreateCompatibleDC(NULL);
  308. hbmT = SelectObject(hdc, hbm);
  309. }
  310. dwSize = (DWORD)pbm->bmHeight * (DWORD)pbm->bmWidthBytes;
  311. if (IsBadHugeWritePtr((LPVOID)pbm->bmBits, dwSize))
  312. {
  313. if (hdc)
  314. {
  315. SelectObject(hdc, hbmT);
  316. DeleteDC(hdc);
  317. }
  318. return NULL;
  319. }
  320. if (p)
  321. {
  322. UINT u;
  323. hmemcpy(p, pbm, min(cb, sizeof(IBITMAP)));
  324. pbm = p;
  325. u = GetBitmapType();
  326. pbm->bmType = u & BM_TYPE;
  327. if (cb > sizeof(BITMAP))
  328. {
  329. pbm->bmBitmapInfo = 0;
  330. pbm->bmNextScan = pbm->bmWidthBytes * pbm->bmPlanes;
  331. if (u & BM_BOTTOMTOTOP)
  332. {
  333. pbm->bmOffset = 0;
  334. }
  335. else
  336. {
  337. pbm->bmOffset = (long)pbm->bmNextScan * (pbm->bmHeight-1);
  338. pbm->bmNextScan = -pbm->bmNextScan;
  339. pbm->bmFillBytes = -pbm->bmFillBytes;
  340. }
  341. //
  342. // see if this particular bitmap is HUGE
  343. //
  344. if (!(u & BM_HUGE) || (DWORD)pbm->bmHeight * pbm->bmWidthBytes < 64l*1024)
  345. {
  346. pbm->bmFillBytes = 0;
  347. pbm->bmScanSegment = pbm->bmHeight;
  348. }
  349. else
  350. {
  351. if (pbm->bmOffset)
  352. pbm->bmOffset -= (long)((pbm->bmHeight-1) / pbm->bmScanSegment) * pbm->bmFillBytes;
  353. }
  354. }
  355. }
  356. if (hdc)
  357. {
  358. SelectObject(hdc, hbmT);
  359. DeleteDC(hdc);
  360. }
  361. return (LPVOID)pbm->bmBits;
  362. }
  363. /////////////////////////////////////////////////////////////////////////////
  364. //
  365. // SetPixel
  366. //
  367. // some cards cant't seam to do SetPixel right it is amazing they work at all
  368. //
  369. /////////////////////////////////////////////////////////////////////////////
  370. static void SetPixelX(HDC hdc, int x, int y, COLORREF rgb)
  371. {
  372. RECT rc;
  373. rc.left = x;
  374. rc.top = y;
  375. rc.right = x+1;
  376. rc.bottom = y+1;
  377. SetBkColor(hdc, rgb);
  378. ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
  379. }
  380. #define SetPixel SetPixelX
  381. ///////////////////////////////////////////////////////////////////////////////
  382. //
  383. // GetSurfaceType
  384. //
  385. ///////////////////////////////////////////////////////////////////////////////
  386. #define BCODE _based(_segname("_CODE"))
  387. static BYTE BCODE bits8[] = {0x00,0xF9,0xFA,0xFC,0xFF};
  388. static WORD BCODE bits555[] = {0x0000,0x7C00,0x03E0,0x001F,0x7FFF};
  389. static WORD BCODE bits5551[]= {0x8000,0xFC00,0x83E0,0x801F,0xFFFF};
  390. static WORD BCODE bits565[] = {0x0000,0xF800,0x07E0,0x001F,0xFFFF};
  391. static BYTE BCODE bitsBGR[] = {0x00,0x00,0x00, 0x00,0x00,0xFF, 0x00,0xFF,0x00, 0xFF,0x00,0x00, 0xFF,0xFF,0xFF};
  392. static BYTE BCODE bitsRGB[] = {0x00,0x00,0x00, 0xFF,0x00,0x00, 0x00,0xFF,0x00, 0x00,0x00,0xFF, 0xFF,0xFF,0xFF};
  393. static DWORD BCODE bitsRGBX[]= {0x000000, 0x0000FF, 0x00FF00, 0xFF0000, 0xFFFFFF};
  394. static DWORD BCODE bitsBGRX[]= {0x000000, 0xFF0000, 0x00FF00, 0x0000FF, 0xFFFFFF};
  395. void FAR TestSurfaceType(HDC hdc, int x, int y)
  396. {
  397. PatBlt(hdc, x, y, 5, 1, BLACKNESS);
  398. SetPixel(hdc, x+0, y, RGB(000,000,000));
  399. SetPixel(hdc, x+1, y, RGB(255,000,000));
  400. SetPixel(hdc, x+2, y, RGB(000,255,000));
  401. SetPixel(hdc, x+3, y, RGB(000,000,255));
  402. SetPixel(hdc, x+4, y, RGB(255,255,255));
  403. GetPixel(hdc, x, y);
  404. }
  405. UINT FAR GetSurfaceType(LPVOID lpBits)
  406. {
  407. #define TESTFMT(a,n) \
  408. if (_fmemcmp(lpBits, (LPVOID)a, sizeof(a)) == 0) return n;
  409. TESTFMT(bits8, BM_8BIT);
  410. TESTFMT(bits555, BM_16555);
  411. TESTFMT(bits5551, BM_16555);
  412. TESTFMT(bits565, BM_16565);
  413. TESTFMT(bitsRGB, BM_24RGB);
  414. TESTFMT(bitsBGR, BM_24BGR);
  415. TESTFMT(bitsRGBX, BM_32RGB);
  416. TESTFMT(bitsBGRX, BM_32BGR);
  417. return 0;
  418. }
  419. ///////////////////////////////////////////////////////////////////////////////
  420. //
  421. // GetBitmapType
  422. //
  423. // return the bitmap type that the display driver uses
  424. //
  425. ///////////////////////////////////////////////////////////////////////////////
  426. UINT FAR GetBitmapType()
  427. {
  428. BITMAP bm;
  429. HBITMAP hbm;
  430. HBITMAP hbmT;
  431. HDC hdc;
  432. UINT u;
  433. BYTE bits[20*4*2];
  434. static UINT wBitmapType = 0xFFFF;
  435. if (wBitmapType != 0xFFFF)
  436. return wBitmapType;
  437. //
  438. // create a test bitmap (<64k)
  439. //
  440. hdc = GetDC(NULL);
  441. if (hdc == NULL) {
  442. return 0;
  443. }
  444. hbm = CreateCompatibleBitmap(hdc,20,2);
  445. ReleaseDC(NULL, hdc);
  446. if (hbm == NULL) {
  447. return 0;
  448. }
  449. hdc = CreateCompatibleDC(NULL);
  450. if (hdc == NULL) {
  451. DeleteObject(hbm);
  452. return 0;
  453. }
  454. hbmT = SelectObject(hdc, hbm);
  455. if (GetObject(hbm, sizeof(bm), &bm) == 0) {
  456. SelectObject(hdc, hbmT);
  457. DeleteObject(hbm);
  458. DeleteDC(hdc);
  459. return 0;
  460. }
  461. PatBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, BLACKNESS);
  462. TestSurfaceType(hdc, 0, 0);
  463. GetBitmapBits(hbm, sizeof(bits), bits);
  464. u = GetSurfaceType(bits);
  465. if (u == 0) {
  466. u = GetSurfaceType(bits + bm.bmWidthBytes);
  467. if (u)
  468. u |= BM_BOTTOMTOTOP;
  469. }
  470. #ifndef WIN32
  471. if (u) {
  472. BYTE _huge *pb;
  473. UINT dy,w;
  474. //
  475. // see if bitmap(s) are huge format
  476. //
  477. dy = (UINT)(0x10000l/bm.bmWidthBytes) + 1;
  478. hbm = CreateCompatibleBitmap(hdc,bm.bmWidth,dy);
  479. DeleteObject(SelectObject(hdc, hbm));
  480. PatBlt(hdc, 0, 0, bm.bmWidth, dy, BLACKNESS);
  481. pb = (BYTE _huge *)LockBitmap(hbm);
  482. if (pb == NULL || OFFSETOF(pb) != 0)
  483. ; // cant lock bitmaps
  484. else {
  485. u |= BM_CANLOCK;
  486. w = (dy-1) * bm.bmWidthBytes;
  487. pb[64l*1024] = 0;
  488. pb[w] = 0;
  489. if (u & BM_BOTTOMTOTOP)
  490. SetPixel(hdc, 0, 0, RGB(255,255,255));
  491. else
  492. SetPixel(hdc, 0, dy-1, RGB(255,255,255));
  493. if (pb[64l*1024] != 0 && pb[w] == 0)
  494. u |= BM_HUGE;
  495. else if (pb[64l*1024] == 0 && pb[w] != 0)
  496. ;
  497. else
  498. u = 0;
  499. }
  500. }
  501. #endif
  502. SelectObject(hdc, hbmT);
  503. DeleteObject(hbm);
  504. DeleteDC(hdc);
  505. wBitmapType = u;
  506. return u;
  507. }
  508. //////////////////////////////////////////////////////////////////////////////
  509. //
  510. // returns the PDevice of the given physical or memory DC
  511. //
  512. // return the bitmap type that the display driver uses
  513. //
  514. ///////////////////////////////////////////////////////////////////////////////
  515. LPVOID FAR GetPDevice(HDC hdc)
  516. {
  517. HANDLE h;
  518. HBITMAP hbm;
  519. HBITMAP hbmT;
  520. HDC hdcT=NULL;
  521. IBITMAP FAR *pbm;
  522. LPVOID lpPDevice = NULL;
  523. // GDI.403
  524. static HANDLE (FAR PASCAL *GdiGetBitmapHandle)(HBITMAP hbm, HANDLE h);
  525. if (GdiGetBitmapHandle == NULL)
  526. (FARPROC)GdiGetBitmapHandle = GetProcAddress(GetModuleHandle(TEXT("GDI")),(LPCSTR)MAKEINTATOM(403));
  527. if (GdiGetBitmapHandle == NULL)
  528. return NULL;
  529. hbm = CreateBitmap(1,1,1,1,NULL);
  530. //
  531. // first try the passed DC if it is a bitmap/DC
  532. //
  533. hbmT = SelectBitmap(hdc, hbm);
  534. if (hbmT != NULL)
  535. {
  536. //
  537. // it is a memory DC.
  538. //
  539. h = GdiGetBitmapHandle(hbmT, 0);
  540. }
  541. else
  542. {
  543. //
  544. // it is a physical DC.
  545. //
  546. hdcT = CreateCompatibleDC(hdc);
  547. hbmT = SelectBitmap(hdcT, hbm);
  548. h = GdiGetBitmapHandle(hbm, 0);
  549. }
  550. if (h == NULL)
  551. goto exit;
  552. pbm = (IBITMAP FAR *)GlobalLock(h);
  553. if (IsBadReadPtr(pbm, sizeof(IBITMAP)))
  554. goto exit;
  555. if (pbm)
  556. pbm = (IBITMAP FAR *)pbm->bmlpPDevice;
  557. else
  558. pbm = NULL;
  559. if (IsBadReadPtr(pbm, 2))
  560. goto exit;
  561. lpPDevice = (LPVOID)pbm;
  562. exit:
  563. if (hdcT)
  564. {
  565. SelectObject(hdcT, hbmT);
  566. DeleteObject(hdcT);
  567. }
  568. else
  569. {
  570. SelectObject(hdc, hbmT);
  571. }
  572. DeleteObject(hbm);
  573. return lpPDevice;
  574. }