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.

1448 lines
32 KiB

  1. //
  2. // BitmapObj.CPP
  3. // Bitmap objects:
  4. //
  5. // Copyright Microsoft 1998-
  6. //
  7. #include "precomp.h"
  8. #include "NMWbObj.h"
  9. BitmapObj::BitmapObj (BitmapCreatePDU * pbitmapCreatePDU)
  10. {
  11. ResetAttrib();
  12. SetType(bitmapCreatePDU_chosen);
  13. SetPenThickness(0);
  14. SetMyWorkspace(NULL);
  15. m_lpTransparencyMask = NULL;
  16. m_lpbiImage = NULL;
  17. m_lpBitMask = NULL;
  18. m_hSaveBitmap = NULL;
  19. m_hOldBitmap = NULL;
  20. m_hIcon = NULL;
  21. m_fMoreToFollow = TRUE;
  22. //
  23. // Created remotely, not selected, not editing or deleting.
  24. //
  25. ClearCreationFlags();
  26. ClearSelectionFlags();
  27. ClearEditionFlags();
  28. ClearDeletionFlags();
  29. if(pbitmapCreatePDU->bitmapFormatHeader.choice != bitmapHeaderNonStandard_chosen)
  30. {
  31. ERROR_OUT(("Only Handle uncompresed bitmaps"));
  32. return;
  33. }
  34. SetThisObjectHandle(pbitmapCreatePDU->bitmapHandle);
  35. UINT workspaceHandle;
  36. UINT planeID;
  37. m_ToolType = GetBitmapDestinationAddress(&pbitmapCreatePDU->destinationAddress, &workspaceHandle, &planeID);
  38. SetWorkspaceHandle(workspaceHandle);
  39. SetPlaneID(planeID);
  40. //
  41. // Get bitmap attributes
  42. //
  43. if(pbitmapCreatePDU->bit_mask & BitmapCreatePDU_attributes_present)
  44. {
  45. GetBitmapAttrib(pbitmapCreatePDU->attributes);
  46. }
  47. //
  48. // Get bitmap anchor point
  49. //
  50. if(pbitmapCreatePDU->bit_mask & BitmapCreatePDU_anchorPoint_present)
  51. {
  52. SetAnchorPoint(pbitmapCreatePDU->anchorPoint.xCoordinate, pbitmapCreatePDU->anchorPoint.yCoordinate);
  53. }
  54. //
  55. // Get bitmap size
  56. //
  57. m_bitmapSize.x = pbitmapCreatePDU->bitmapSize.width;
  58. m_bitmapSize.y = pbitmapCreatePDU->bitmapSize.height;
  59. RECT rect;
  60. rect.top = pbitmapCreatePDU->anchorPoint.yCoordinate;
  61. rect.left = pbitmapCreatePDU->anchorPoint.xCoordinate;
  62. rect.bottom = pbitmapCreatePDU->anchorPoint.yCoordinate + m_bitmapSize.y;
  63. rect.right = pbitmapCreatePDU->anchorPoint.xCoordinate + m_bitmapSize.x;
  64. SetRect(&rect);
  65. //
  66. // Get bitmap region of interest
  67. //
  68. if(pbitmapCreatePDU->bit_mask & bitmapRegionOfInterest_present)
  69. {
  70. m_bitmapRegionOfInterest.left = pbitmapCreatePDU->bitmapRegionOfInterest.upperLeft.xCoordinate;
  71. m_bitmapRegionOfInterest.top = pbitmapCreatePDU->bitmapRegionOfInterest.upperLeft.yCoordinate;
  72. m_bitmapRegionOfInterest.right = pbitmapCreatePDU->bitmapRegionOfInterest.lowerRight.xCoordinate;
  73. m_bitmapRegionOfInterest.bottom = pbitmapCreatePDU->bitmapRegionOfInterest.lowerRight.yCoordinate;
  74. }
  75. //
  76. // Get the bitmap pixel aspect ration
  77. //
  78. m_pixelAspectRatio = pbitmapCreatePDU->pixelAspectRatio.choice;
  79. if(pbitmapCreatePDU->bit_mask & BitmapCreatePDU_scaling_present)
  80. {
  81. m_scaling.x = pbitmapCreatePDU->scaling.xCoordinate;
  82. m_scaling.y = pbitmapCreatePDU->scaling.yCoordinate;
  83. }
  84. //
  85. // Non standard bitmap
  86. //
  87. if((pbitmapCreatePDU->bit_mask & BitmapCreatePDU_nonStandardParameters_present) &&
  88. pbitmapCreatePDU->nonStandardParameters->value.nonStandardIdentifier.choice == h221nonStandard_chosen)
  89. {
  90. m_bitmapData.m_length = pbitmapCreatePDU->nonStandardParameters->value.data.length;
  91. m_lpbiImage = (LPBITMAPINFOHEADER)::GlobalAlloc(GPTR, m_bitmapData.m_length);
  92. memcpy(m_lpbiImage, // pColor is now pointing to the begining of the bitmap bits
  93. pbitmapCreatePDU->nonStandardParameters->value.data.value,
  94. m_bitmapData.m_length);
  95. }
  96. m_fMoreToFollow = pbitmapCreatePDU->moreToFollow;
  97. // Create a memory DC compatible with the display
  98. m_hMemDC = ::CreateCompatibleDC(NULL);
  99. //
  100. // If this is a remote pointer
  101. //
  102. if(m_ToolType == TOOLTYPE_REMOTEPOINTER)
  103. {
  104. CreateColoredIcon(0, m_lpbiImage, m_lpTransparencyMask);
  105. CreateSaveBitmap();
  106. }
  107. }
  108. void BitmapObj::Continue (BitmapCreateContinuePDU * pbitmapCreateContinuePDU)
  109. {
  110. //
  111. // Get the continuation bitmap data
  112. //
  113. BYTE * pNewBitmapBuffer = NULL;
  114. ULONG length = 0;
  115. BYTE* pSentBuff;
  116. //
  117. // Allocate a buffer for the previous data and the one we just got, copy the old data in the new buffer
  118. //
  119. if(pbitmapCreateContinuePDU->bit_mask == BitmapCreateContinuePDU_nonStandardParameters_present)
  120. {
  121. length = pbitmapCreateContinuePDU->nonStandardParameters->value.data.length;
  122. pSentBuff = pbitmapCreateContinuePDU->nonStandardParameters->value.data.value;
  123. }
  124. else
  125. {
  126. return;
  127. }
  128. //
  129. // Copy the old data
  130. //
  131. pNewBitmapBuffer = (BYTE *)::GlobalAlloc(GPTR, m_bitmapData.m_length + length);
  132. if(pNewBitmapBuffer == NULL)
  133. {
  134. TRACE_DEBUG(("Could not allocate memory size = %d)", m_bitmapData.m_length + length));
  135. return;
  136. }
  137. memcpy(pNewBitmapBuffer, m_lpbiImage, m_bitmapData.m_length);
  138. TRACE_DEBUG(("BitmapObj::Continue length = %d moreToFollow = %d)", length, pbitmapCreateContinuePDU->moreToFollow));
  139. //
  140. // Copy the new data
  141. //
  142. memcpy(pNewBitmapBuffer + m_bitmapData.m_length, pSentBuff, length);
  143. //
  144. // delete the old buffer
  145. //
  146. ::GlobalFree((HGLOBAL)m_lpbiImage);
  147. //
  148. // Update bitmap data info
  149. //
  150. m_lpbiImage = (LPBITMAPINFOHEADER)pNewBitmapBuffer;
  151. m_bitmapData.m_length += length;
  152. m_lpbiImage->biSizeImage += length;
  153. m_fMoreToFollow = pbitmapCreateContinuePDU->moreToFollow;
  154. }
  155. BitmapObj::BitmapObj (UINT toolType)
  156. {
  157. SetType(bitmapCreatePDU_chosen);
  158. ResetAttrib();
  159. SetOwnerID(g_MyMemberID);
  160. SetMyWorkspace(NULL);
  161. m_ToolType = toolType;
  162. m_lpTransparencyMask = NULL;
  163. m_lpbiImage = NULL;
  164. m_lpBitMask = NULL;
  165. m_hSaveBitmap = NULL;
  166. m_hOldBitmap = NULL;
  167. m_fMoreToFollow = FALSE;
  168. //
  169. // Created locally, not selected, not editing or deleting.
  170. //
  171. CreatedLocally();
  172. ClearSelectionFlags();
  173. ClearEditionFlags();
  174. ClearDeletionFlags();
  175. SetPenThickness(0);
  176. //
  177. // Set it to 0 so it boundsRect == rect
  178. //
  179. RECT rect;
  180. ::SetRectEmpty(&rect);
  181. SetRect(&rect);
  182. SetWorkspaceHandle(g_pCurrentWorkspace == NULL ? 0 : g_pCurrentWorkspace->GetWorkspaceHandle());
  183. SetPlaneID(1);
  184. SetViewState(unselected_chosen);
  185. SetZOrder(front);
  186. SetAnchorPoint(0,0);
  187. if(m_ToolType == TOOLTYPE_REMOTEPOINTER)
  188. {
  189. // We haven't yet created our mem DC
  190. m_hSaveBitmap = NULL;
  191. m_hOldBitmap = NULL;
  192. // Set the bounding rectangle of the object
  193. rect.left = 0;
  194. rect.top = 0;
  195. rect.right = ::GetSystemMetrics(SM_CXICON);
  196. rect.bottom = ::GetSystemMetrics(SM_CYICON);
  197. SetRect(&rect);
  198. }
  199. // Show that we do not have an icon for drawing yet
  200. m_hIcon = NULL;
  201. // Create a memory DC compatible with the display
  202. m_hMemDC = ::CreateCompatibleDC(NULL);
  203. }
  204. BitmapObj::~BitmapObj( void )
  205. {
  206. RemoveObjectFromResendList(this);
  207. RemoveObjectFromRequestHandleList(this);
  208. if(GetMyWorkspace() != NULL && WasDeletedLocally())
  209. {
  210. OnObjectDelete();
  211. }
  212. ::GlobalFree((HGLOBAL)m_lpbiImage);
  213. DeleteSavedBitmap();
  214. if (m_hMemDC != NULL)
  215. {
  216. ::DeleteDC(m_hMemDC);
  217. m_hMemDC = NULL;
  218. }
  219. if(g_pMain && g_pMain->m_pLocalRemotePointer == this)
  220. {
  221. GetAnchorPoint(&g_pMain->m_localRemotePointerPosition);
  222. g_pMain->m_pLocalRemotePointer = NULL;
  223. g_pMain->m_TB.PopUp(IDM_REMOTE);
  224. }
  225. if(m_lpTransparencyMask)
  226. {
  227. delete m_lpTransparencyMask;
  228. m_lpTransparencyMask = NULL;
  229. }
  230. if(m_hIcon)
  231. {
  232. ::DestroyIcon(m_hIcon);
  233. }
  234. }
  235. void BitmapObj::BitmapEditObj (BitmapEditPDU * pbitmapEditPDU )
  236. {
  237. RECT rect;
  238. POSITION pos;
  239. POINT anchorPoint;
  240. LONG deltaX = 0;
  241. LONG deltaY = 0;
  242. TRACE_MSG(("bitmapHandle = %d", pbitmapEditPDU->bitmapHandle ));
  243. //
  244. // Was edited remotely
  245. //
  246. ClearEditionFlags();
  247. //
  248. // Read attributes
  249. //
  250. if(pbitmapEditPDU->bit_mask & BitmapEditPDU_attributeEdits_present)
  251. {
  252. GetBitmapAttrib((PBitmapCreatePDU_attributes)pbitmapEditPDU->attributeEdits);
  253. }
  254. //
  255. // Change the anchor point
  256. //
  257. GetAnchorPoint(&anchorPoint);
  258. if(pbitmapEditPDU->bit_mask & BitmapEditPDU_anchorPointEdit_present)
  259. {
  260. TRACE_DEBUG(("Old anchor point (%d,%d)", anchorPoint.x, anchorPoint.y));
  261. TRACE_DEBUG(("New anchor point (%d,%d)",
  262. pbitmapEditPDU->anchorPointEdit.xCoordinate, pbitmapEditPDU->anchorPointEdit.yCoordinate));
  263. //
  264. // Get the delta from previous anchor point
  265. //
  266. deltaX = pbitmapEditPDU->anchorPointEdit.xCoordinate - anchorPoint.x;
  267. deltaY = pbitmapEditPDU->anchorPointEdit.yCoordinate - anchorPoint.y;
  268. TRACE_DEBUG(("Delta (%d,%d)", deltaX , deltaY));
  269. //
  270. // Was edited remotely
  271. //
  272. ClearEditionFlags();
  273. //
  274. // Set new anchor point
  275. //
  276. anchorPoint.x = pbitmapEditPDU->anchorPointEdit.xCoordinate;
  277. anchorPoint.y = pbitmapEditPDU->anchorPointEdit.yCoordinate;
  278. SetAnchorPoint(anchorPoint.x, anchorPoint.y);
  279. GetRect(&rect);
  280. ::OffsetRect(&rect, deltaX, deltaY);
  281. SetRect(&rect);
  282. }
  283. // if(pbitmapEditPDU->bit_mask & BitmapEditPDU_nonStandardParameters_present)
  284. // {
  285. // ; // Do the non Standard Edit PDU NYI
  286. // }
  287. if(HasAnchorPointChanged())
  288. {
  289. g_pDraw->EraseInitialDrawFinal(0 - deltaX,0 - deltaY, FALSE, (T126Obj*)this);
  290. GetBoundsRect(&rect);
  291. g_pDraw->InvalidateSurfaceRect(&rect,TRUE);
  292. }
  293. else if(HasZOrderChanged())
  294. {
  295. if(GetZOrder() == front)
  296. {
  297. g_pDraw->BringToTopSelection(FALSE, this);
  298. }
  299. else
  300. {
  301. g_pDraw->SendToBackSelection(FALSE, this);
  302. }
  303. }
  304. //
  305. // If it just select/unselected it
  306. //
  307. else if(HasViewStateChanged())
  308. {
  309. }
  310. else
  311. {
  312. Draw();
  313. }
  314. //
  315. // Reset all the attributes
  316. //
  317. ResetAttrib();
  318. }
  319. void BitmapObj::GetBitmapAttrib(PBitmapCreatePDU_attributes pAttribPDU)
  320. {
  321. PBitmapCreatePDU_attributes attributes;
  322. attributes = (PBitmapCreatePDU_attributes)pAttribPDU;
  323. while(attributes)
  324. {
  325. switch(attributes->value.choice)
  326. {
  327. case(BitmapAttribute_viewState_chosen):
  328. {
  329. if((attributes->value.u.viewState).choice != nonStandardViewState_chosen)
  330. {
  331. SetViewState(attributes->value.u.viewState.choice);
  332. //
  333. // If the other node is selecting the drawing or unselecting
  334. //
  335. if(attributes->value.u.viewState.choice == selected_chosen)
  336. {
  337. SelectedRemotely();
  338. }
  339. else if(attributes->value.u.viewState.choice == unselected_chosen)
  340. {
  341. ClearSelectionFlags();
  342. }
  343. TRACE_MSG(("Attribute viewState %d", attributes->value.u.viewState.choice));
  344. }
  345. else
  346. {
  347. // Do the non Standard view state
  348. ;
  349. }
  350. break;
  351. }
  352. case(BitmapAttribute_zOrder_chosen):
  353. {
  354. SetZOrder(attributes->value.u.zOrder);
  355. TRACE_MSG(("Attribute zOrder %d", attributes->value.u.zOrder));
  356. break;
  357. }
  358. case(BitmapAttribute_transparencyMask_chosen):
  359. {
  360. TRACE_MSG(("Attribute transparencyMask"));
  361. if(attributes->value.u.transparencyMask.bitMask.choice == uncompressed_chosen)
  362. {
  363. m_SizeOfTransparencyMask = attributes->value.u.transparencyMask.bitMask.u.uncompressed.length;
  364. DBG_SAVE_FILE_LINE
  365. m_lpTransparencyMask = new BYTE[m_SizeOfTransparencyMask];
  366. memcpy(m_lpTransparencyMask, attributes->value.u.transparencyMask.bitMask.u.uncompressed.value, m_SizeOfTransparencyMask);
  367. //
  368. // Asn wants it top bottom left right
  369. //
  370. // BYTE swapByte;
  371. // for (UINT i=0; i <m_SizeOfTransparencyMask ; i++)
  372. // {
  373. // swapByte = attributes->value.u.transparencyMask.bitMask.u.uncompressed.value[i];
  374. // m_lpTransparencyMask [i] = ~(((swapByte >> 4) & 0x0f) | ((swapByte << 4)));
  375. // }
  376. }
  377. break;
  378. }
  379. case(DrawingAttribute_nonStandardAttribute_chosen):
  380. {
  381. break; // NYI
  382. }
  383. default:
  384. WARNING_OUT(("Invalid attributes choice"));
  385. break;
  386. }
  387. attributes = attributes->next;
  388. }
  389. }
  390. void BitmapObj::CreateNonStandard24BitBitmap(BitmapCreatePDU * pBitmapCreatePDU)
  391. {
  392. pBitmapCreatePDU->bit_mask |= BitmapCreatePDU_nonStandardParameters_present;
  393. //
  394. // Create the bitmpa header because it is not optional
  395. //
  396. pBitmapCreatePDU->bitmapFormatHeader.choice = bitmapHeaderNonStandard_chosen;
  397. pBitmapCreatePDU->bitmapFormatHeader.u.bitmapHeaderNonStandard.nonStandardIdentifier.choice = bitmapHeaderNonStandard_chosen;
  398. CreateNonStandardPDU(&pBitmapCreatePDU->bitmapFormatHeader.u.bitmapHeaderNonStandard, NonStandard24BitBitmapID);
  399. pBitmapCreatePDU->bitmapFormatHeader.u.bitmapHeaderNonStandard.data.length = 0;
  400. pBitmapCreatePDU->bitmapFormatHeader.u.bitmapHeaderNonStandard.data.value = NULL;
  401. DBG_SAVE_FILE_LINE
  402. pBitmapCreatePDU->nonStandardParameters = new BitmapCreatePDU_nonStandardParameters;
  403. pBitmapCreatePDU->nonStandardParameters->next = NULL;
  404. CreateNonStandardPDU(&pBitmapCreatePDU->nonStandardParameters->value, NonStandard24BitBitmapID);
  405. }
  406. void BitmapObj::CreateBitmapCreatePDU(CWBOBLIST * pCreatePDUList)
  407. {
  408. if(m_lpbiImage == NULL)
  409. {
  410. TRACE_MSG(("We dont have a bitmap structure to sent"));
  411. return;
  412. }
  413. SIPDU *sipdu = NULL;
  414. DBG_SAVE_FILE_LINE
  415. sipdu = (SIPDU *) new BYTE[sizeof(SIPDU)];
  416. if(!sipdu)
  417. {
  418. TRACE_MSG(("Failed to create sipdu"));
  419. ::PostMessage(g_pMain->m_hwnd, WM_USER_DISPLAY_ERROR, WBFE_RC_WINDOWS, 0);
  420. return;
  421. }
  422. //
  423. // This is the first bitmap create pdu
  424. //
  425. sipdu->choice = bitmapCreatePDU_chosen;
  426. BitmapCreatePDU *pCreatePDU = &sipdu->u.bitmapCreatePDU;
  427. pCreatePDU->bit_mask = 0;
  428. pCreatePDU->nonStandardParameters = NULL;
  429. //
  430. // Pass the bitmap Handle
  431. //
  432. pCreatePDU->bitmapHandle = GetThisObjectHandle();
  433. //
  434. // Pass the destination adress
  435. //
  436. if( m_ToolType == TOOLTYPE_REMOTEPOINTER)
  437. {
  438. pCreatePDU->destinationAddress.choice = softCopyPointerPlane_chosen;
  439. pCreatePDU->destinationAddress.u.softCopyPointerPlane.workspaceHandle = GetMyWorkspace()->GetWorkspaceHandle();
  440. }
  441. else
  442. {
  443. pCreatePDU->destinationAddress.choice = BitmapDestinationAddress_softCopyImagePlane_chosen;
  444. pCreatePDU->destinationAddress.u.softCopyImagePlane.workspaceHandle = GetMyWorkspace()->GetWorkspaceHandle();
  445. pCreatePDU->destinationAddress.u.softCopyImagePlane.plane = (DataPlaneID)GetPlaneID();
  446. }
  447. //
  448. // Pass the bitmap attributes
  449. //
  450. pCreatePDU->bit_mask |=BitmapCreatePDU_attributes_present;
  451. SetBitmapAttrib(&pCreatePDU->attributes);
  452. //
  453. // Pass the anchor point
  454. //
  455. pCreatePDU->bit_mask |=BitmapCreatePDU_anchorPoint_present;
  456. POINT point;
  457. GetAnchorPoint(&point);
  458. pCreatePDU->anchorPoint.xCoordinate = point.x;
  459. pCreatePDU->anchorPoint.yCoordinate = point.y;
  460. //
  461. // Pass the bitmap size
  462. //
  463. pCreatePDU->bitmapSize.width = m_bitmapSize.x;
  464. pCreatePDU->bitmapSize.height = m_bitmapSize.y;
  465. //
  466. // Pass bitmap region of interest
  467. //
  468. pCreatePDU->bit_mask |=bitmapRegionOfInterest_present;
  469. BitmapRegion bitmapRegionOfInterest;
  470. //
  471. // Pass pixel aspect ratio
  472. //
  473. pCreatePDU->pixelAspectRatio.choice = PixelAspectRatio_square_chosen;
  474. //
  475. // Pass scaling factor
  476. //
  477. // pCreatePDU->bit_mask |=BitmapCreatePDU_scaling_present;
  478. // pCreatePDU->scaling.xCoordinate = 0;
  479. // pCreatePDU->scaling.yCoordinate = 0;
  480. //
  481. // Pass check points
  482. //
  483. // pCreatePDU->bit_mask |=checkpoints_present;
  484. // pCreatePDU->checkpoints;
  485. //
  486. // JOSEF If we want > 8 have to recalculate to 24
  487. //
  488. LPSTR pDIB_bits;
  489. LPBITMAPINFOHEADER lpbi8 = m_lpbiImage;
  490. HDC hdc = NULL;
  491. HBITMAP hbmp = NULL;
  492. DWORD sizeOfBmpData = 0;
  493. if(!g_pNMWBOBJ->CanDo24BitBitmaps())
  494. {
  495. hdc = GetDC(NULL);
  496. BITMAPINFOHEADER lpbmih;
  497. if(lpbi8->biBitCount > MAX_BITS_PERPIXEL)
  498. {
  499. lpbmih.biSize = sizeof(BITMAPINFOHEADER);
  500. lpbmih.biWidth = lpbi8->biWidth;
  501. lpbmih.biHeight = lpbi8->biHeight;
  502. lpbmih.biPlanes = 1;
  503. lpbmih.biBitCount = MAX_BITS_PERPIXEL;
  504. lpbmih.biCompression = lpbi8->biCompression;
  505. lpbmih.biSizeImage = lpbi8->biSizeImage;
  506. lpbmih.biXPelsPerMeter = lpbi8->biXPelsPerMeter;
  507. lpbmih.biYPelsPerMeter = lpbi8->biYPelsPerMeter;
  508. lpbmih.biClrUsed = lpbi8->biClrUsed;
  509. lpbmih.biClrImportant = lpbi8->biClrImportant;
  510. hbmp = CreateDIBitmap(hdc, &lpbmih, CBM_INIT, DIB_Bits(lpbi8),(LPBITMAPINFO)lpbi8, DIB_RGB_COLORS);
  511. lpbi8 = DIB_FromBitmap(hbmp, NULL, FALSE, FALSE);
  512. }
  513. }
  514. pDIB_bits = (LPSTR)lpbi8;
  515. sizeOfBmpData = DIB_TotalLength(lpbi8);
  516. //
  517. // Sending data
  518. //
  519. BOOL bMoreToFollow = FALSE;
  520. DWORD length = sizeOfBmpData;
  521. pCreatePDU->bitmapData.bit_mask = 0;
  522. if(sizeOfBmpData > MAX_BITMAP_DATA)
  523. {
  524. length = MAX_BITMAP_DATA;
  525. bMoreToFollow = TRUE;
  526. }
  527. pCreatePDU->moreToFollow = (ASN1bool_t)bMoreToFollow;
  528. //
  529. // Pass the bitmap info
  530. //
  531. pCreatePDU->bit_mask |= BitmapCreatePDU_nonStandardParameters_present;
  532. CreateNonStandard24BitBitmap(&sipdu->u.bitmapCreatePDU);
  533. pCreatePDU->nonStandardParameters->value.data.length = length;
  534. pCreatePDU->nonStandardParameters->value.data.value = (ASN1octet_t *)pDIB_bits;
  535. //
  536. // We are not passing it into the data field
  537. //
  538. pCreatePDU->bitmapData.bit_mask = 0;
  539. pCreatePDU->bitmapData.data.length = 1;
  540. pCreatePDUList->AddTail(sipdu);
  541. BitmapCreateContinuePDU * pCreateContinuePDU;
  542. while(bMoreToFollow)
  543. {
  544. //
  545. // Advance the pointer
  546. //
  547. pDIB_bits += MAX_BITMAP_DATA;
  548. sizeOfBmpData-= MAX_BITMAP_DATA;
  549. if(sizeOfBmpData > MAX_BITMAP_DATA)
  550. {
  551. length = MAX_BITMAP_DATA;
  552. }
  553. else
  554. {
  555. length = sizeOfBmpData;
  556. bMoreToFollow = FALSE;
  557. }
  558. //
  559. // Create a new BitmapCreateContinuePDU
  560. //
  561. sipdu = NULL;
  562. DBG_SAVE_FILE_LINE
  563. sipdu = (SIPDU *) new BYTE[sizeof(SIPDU)];
  564. if(!sipdu)
  565. {
  566. TRACE_MSG(("Failed to create sipdu"));
  567. ::PostMessage(g_pMain->m_hwnd, WM_USER_DISPLAY_ERROR, WBFE_RC_WINDOWS, 0);
  568. return;
  569. }
  570. sipdu->choice = bitmapCreateContinuePDU_chosen;
  571. pCreateContinuePDU = &sipdu->u.bitmapCreateContinuePDU;
  572. pCreateContinuePDU->bit_mask = 0;
  573. pCreateContinuePDU->nonStandardParameters = NULL;
  574. //
  575. // Pass the bitmap Handle
  576. //
  577. pCreateContinuePDU->bitmapHandle = GetThisObjectHandle();
  578. //
  579. // Pass the data
  580. //
  581. pCreateContinuePDU->bit_mask |= BitmapCreateContinuePDU_nonStandardParameters_present;
  582. //
  583. // Pass the bitmap info
  584. //
  585. DBG_SAVE_FILE_LINE
  586. pCreateContinuePDU->nonStandardParameters = new BitmapCreateContinuePDU_nonStandardParameters;
  587. pCreateContinuePDU->nonStandardParameters->next = NULL;
  588. CreateNonStandardPDU(&pCreateContinuePDU->nonStandardParameters->value, NonStandard24BitBitmapID);
  589. pCreateContinuePDU->nonStandardParameters->value.data.length = length;
  590. pCreateContinuePDU->nonStandardParameters->value.data.value = (ASN1octet_t *)pDIB_bits;
  591. //
  592. // We are not passing it into the data field
  593. //
  594. pCreateContinuePDU->bitmapData.bit_mask = 0;
  595. pCreateContinuePDU->bitmapData.data.length = 1;
  596. pCreateContinuePDU->moreToFollow = (ASN1bool_t) bMoreToFollow;
  597. pCreatePDUList->AddTail(sipdu);
  598. }
  599. if(hbmp)
  600. {
  601. DeleteObject(hbmp);
  602. }
  603. if(hdc)
  604. {
  605. ReleaseDC(NULL, hdc);
  606. }
  607. }
  608. void BitmapObj::CreateBitmapEditPDU(BitmapEditPDU *pEditPDU)
  609. {
  610. pEditPDU->bit_mask = (ASN1uint16_t) GetPresentAttribs();
  611. //
  612. // Pass the anchor point
  613. //
  614. if(HasAnchorPointChanged())
  615. {
  616. POINT point;
  617. GetAnchorPoint(&point);
  618. pEditPDU->anchorPointEdit.xCoordinate = point.x;
  619. pEditPDU->anchorPointEdit.yCoordinate = point.y;
  620. }
  621. //
  622. // JOSEF Pass Region of interest (FEATURE)
  623. //
  624. //
  625. // JOSEF Pass scaling (FEATURE)
  626. //
  627. //
  628. // Pass all the changed attributes, if any.
  629. //
  630. pEditPDU->attributeEdits = NULL;
  631. if(pEditPDU->bit_mask & BitmapEditPDU_attributeEdits_present)
  632. {
  633. SetBitmapAttrib((PBitmapCreatePDU_attributes *)&pEditPDU->attributeEdits);
  634. }
  635. pEditPDU->bitmapHandle = GetThisObjectHandle();
  636. }
  637. void BitmapObj::CreateBitmapDeletePDU(BitmapDeletePDU *pDeletePDU)
  638. {
  639. pDeletePDU->bit_mask = 0;
  640. pDeletePDU->bitmapHandle = GetThisObjectHandle();
  641. }
  642. void BitmapObj::AllocateAttrib(PBitmapCreatePDU_attributes *pAttributes)
  643. {
  644. DBG_SAVE_FILE_LINE
  645. PBitmapCreatePDU_attributes pAttrib = (PBitmapCreatePDU_attributes)new BYTE[sizeof(BitmapCreatePDU_attributes)];
  646. if(*pAttributes == NULL)
  647. {
  648. *pAttributes = pAttrib;
  649. pAttrib->next = NULL;
  650. }
  651. else
  652. {
  653. ((PBitmapCreatePDU_attributes)pAttrib)->next = *pAttributes;
  654. *pAttributes = pAttrib;
  655. }
  656. }
  657. void BitmapObj::SetBitmapAttrib(PBitmapCreatePDU_attributes *pattributes)
  658. {
  659. PBitmapCreatePDU_attributes attributes = NULL;
  660. //
  661. // Do the viewState
  662. //
  663. if(HasViewStateChanged())
  664. {
  665. AllocateAttrib(&attributes);
  666. attributes->value.choice = BitmapAttribute_viewState_chosen;
  667. attributes->value.u.viewState.choice = (ASN1choice_t)GetViewState();
  668. }
  669. //
  670. // Do the zOrder
  671. //
  672. if(HasZOrderChanged())
  673. {
  674. AllocateAttrib(&attributes);
  675. attributes->value.choice = BitmapAttribute_zOrder_chosen;
  676. attributes->value.u.zOrder = GetZOrder();
  677. }
  678. //
  679. // Do the Transparency
  680. //
  681. if(HasTransparencyMaskChanged())
  682. {
  683. AllocateAttrib(&attributes);
  684. attributes->value.choice = BitmapAttribute_transparencyMask_chosen;
  685. attributes->value.u.transparencyMask.bit_mask = 0;
  686. attributes->value.u.transparencyMask.bitMask.choice = uncompressed_chosen;
  687. attributes->value.u.transparencyMask.bitMask.u.uncompressed.length = m_SizeOfTransparencyMask;
  688. attributes->value.u.transparencyMask.bitMask.u.uncompressed.value = m_lpTransparencyMask;
  689. }
  690. //
  691. // End of attributes
  692. //
  693. *pattributes = attributes;
  694. }
  695. void BitmapObj::Draw(HDC hDC, BOOL bForcedDraw, BOOL bPrinting)
  696. {
  697. if(!bPrinting)
  698. {
  699. //
  700. // Don't draw anything if we don't belong in this workspace
  701. //
  702. if(GetWorkspaceHandle() != g_pCurrentWorkspace->GetThisObjectHandle())
  703. {
  704. return;
  705. }
  706. }
  707. RECT clipBox;
  708. RECT rect;
  709. GetRect(&rect);
  710. if(hDC == NULL)
  711. {
  712. hDC = g_pDraw->m_hDCCached;
  713. }
  714. MLZ_EntryOut(ZONE_FUNCTION, "BitmapObj::Draw");
  715. // Only draw anything if the bounding rectangle intersects
  716. // the current clip box.
  717. if (::GetClipBox(hDC, &clipBox) == ERROR)
  718. {
  719. WARNING_OUT(("Failed to get clip box"));
  720. }
  721. else if (!::IntersectRect(&clipBox, &clipBox, &rect))
  722. {
  723. TRACE_MSG(("No clip/bounds intersection"));
  724. return;
  725. }
  726. if(m_ToolType == TOOLTYPE_FILLEDBOX)
  727. {
  728. if(m_fMoreToFollow)
  729. {
  730. return;
  731. }
  732. // Set the stretch mode to be used so that scan lines are deleted
  733. // rather than combined. This will tend to preserve color better.
  734. int iOldStretchMode = ::SetStretchBltMode(hDC, STRETCH_DELETESCANS);
  735. // Draw the bitmap
  736. ::StretchDIBits(hDC,
  737. rect.left,
  738. rect.top,
  739. rect.right - rect.left,
  740. rect.bottom - rect.top,
  741. 0,
  742. 0,
  743. (UINT) m_lpbiImage->biWidth,
  744. (UINT) m_lpbiImage->biHeight,
  745. (VOID FAR *) DIB_Bits(m_lpbiImage),
  746. (LPBITMAPINFO)m_lpbiImage,
  747. DIB_RGB_COLORS,
  748. SRCCOPY);
  749. // Restore the stretch mode
  750. ::SetStretchBltMode(hDC, iOldStretchMode);
  751. }
  752. else
  753. {
  754. // Create the save bitmap if necessary
  755. CreateSaveBitmap();
  756. // Draw the icon
  757. ::DrawIcon(hDC, rect.left, rect.top, m_hIcon);
  758. }
  759. }
  760. //
  761. //
  762. // Function: BitmapObj::::FromScreenArea
  763. //
  764. // Purpose: Set the content of the object from an area of the screen
  765. //
  766. //
  767. void BitmapObj::FromScreenArea(LPCRECT lprcScreen)
  768. {
  769. m_lpbiImage = DIB_FromScreenArea(lprcScreen);
  770. if (m_lpbiImage == NULL)
  771. {
  772. ::Message(NULL, (UINT)IDS_MSG_CAPTION, (UINT)IDS_CANTGETBMP, (UINT)MB_OK );
  773. }
  774. else
  775. {
  776. m_bitmapSize.x = m_lpbiImage->biWidth;
  777. m_bitmapSize.y = m_lpbiImage->biHeight;
  778. RECT rect;
  779. GetBoundsRect(&rect);
  780. // Calculate the bounding rectangle from the size of the bitmap
  781. rect.right = rect.left + m_lpbiImage->biWidth;
  782. rect.bottom = rect.top + m_lpbiImage->biHeight;
  783. SetRect(&rect);
  784. }
  785. }
  786. UINT GetBitmapDestinationAddress(BitmapDestinationAddress *destinationAddress, PUINT workspaceHandle, PUINT planeID)
  787. {
  788. UINT toolType = TOOLTYPE_FILLEDBOX;
  789. //
  790. // Get the destination address
  791. //
  792. switch(destinationAddress->choice)
  793. {
  794. case(BitmapDestinationAddress_softCopyImagePlane_chosen):
  795. {
  796. *workspaceHandle = (destinationAddress->u.softCopyImagePlane.workspaceHandle);
  797. *planeID = (destinationAddress->u.softCopyImagePlane.plane);
  798. break;
  799. }
  800. case(BitmapDestinationAddress_softCopyAnnotationPlane_chosen):
  801. {
  802. *workspaceHandle = (destinationAddress->u.softCopyAnnotationPlane.workspaceHandle);
  803. *planeID = (destinationAddress->u.softCopyAnnotationPlane.plane);
  804. break;
  805. }
  806. case(softCopyPointerPlane_chosen):
  807. {
  808. *workspaceHandle = (destinationAddress->u.softCopyPointerPlane.workspaceHandle);
  809. *planeID = (0);
  810. toolType = TOOLTYPE_REMOTEPOINTER;
  811. break;
  812. }
  813. // case(BitmapDestinationAddress_nonStandardDestination_chosen):
  814. // {
  815. // break;
  816. // }
  817. default:
  818. ERROR_OUT(("Invalid destinationAddress"));
  819. break;
  820. }
  821. return toolType;
  822. }
  823. //
  824. // UI Edited the Bitmap Object
  825. //
  826. void BitmapObj::OnObjectEdit(void)
  827. {
  828. g_bContentsChanged = TRUE;
  829. SIPDU *sipdu = NULL;
  830. DBG_SAVE_FILE_LINE
  831. sipdu = (SIPDU *) new BYTE[sizeof(SIPDU)];
  832. if(sipdu)
  833. {
  834. sipdu->choice = bitmapEditPDU_chosen;
  835. CreateBitmapEditPDU(&sipdu->u.bitmapEditPDU);
  836. T120Error rc = SendT126PDU(sipdu);
  837. if(rc == T120_NO_ERROR)
  838. {
  839. SIPDUCleanUp(sipdu);
  840. }
  841. }
  842. else
  843. {
  844. TRACE_MSG(("Failed to create sipdu"));
  845. ::PostMessage(g_pMain->m_hwnd, WM_USER_DISPLAY_ERROR, WBFE_RC_WINDOWS, 0);
  846. }
  847. }
  848. //
  849. // UI Deleted the Bitmap Object
  850. //
  851. void BitmapObj::OnObjectDelete(void)
  852. {
  853. SIPDU *sipdu = NULL;
  854. DBG_SAVE_FILE_LINE
  855. sipdu = (SIPDU *) new BYTE[sizeof(SIPDU)];
  856. if(sipdu)
  857. {
  858. sipdu->choice = bitmapDeletePDU_chosen;
  859. CreateBitmapDeletePDU(&sipdu->u.bitmapDeletePDU);
  860. T120Error rc = SendT126PDU(sipdu);
  861. if(rc == T120_NO_ERROR)
  862. {
  863. SIPDUCleanUp(sipdu);
  864. }
  865. }
  866. else
  867. {
  868. TRACE_MSG(("Failed to create sipdu"));
  869. ::PostMessage(g_pMain->m_hwnd, WM_USER_DISPLAY_ERROR, WBFE_RC_WINDOWS, 0);
  870. }
  871. }
  872. void BitmapObj::GetEncodedCreatePDU(ASN1_BUF *pBuf)
  873. {
  874. pBuf->length = DIB_TotalLength(m_lpbiImage);
  875. pBuf->value = (PBYTE)m_lpbiImage;
  876. }
  877. //
  878. // UI Created a new Bitmap Object
  879. //
  880. void BitmapObj::SendNewObjectToT126Apps(void)
  881. {
  882. SIPDU *sipdu = NULL;
  883. CWBOBLIST BitmapContinueCreatePDUList;
  884. BitmapContinueCreatePDUList.EmptyList();
  885. CreateBitmapCreatePDU(&BitmapContinueCreatePDUList);
  886. T120Error rc = T120_NO_ERROR;
  887. WBPOSITION pos = BitmapContinueCreatePDUList.GetHeadPosition();
  888. while (pos != NULL)
  889. {
  890. sipdu = (SIPDU *) BitmapContinueCreatePDUList.GetNext(pos);
  891. TRACE_DEBUG(("Sending Bitmap >> Bitmap handle = %d", sipdu->u.bitmapCreatePDU.bitmapHandle ));
  892. if(g_bSavingFile && GraphicTool() == TOOLTYPE_REMOTEPOINTER)
  893. {
  894. ; // Don't send Remote pointers to disk
  895. }
  896. else
  897. {
  898. if(!m_fMoreToFollow)
  899. {
  900. rc = SendT126PDU(sipdu);
  901. }
  902. }
  903. if(rc == T120_NO_ERROR)
  904. {
  905. SIPDUCleanUp(sipdu);
  906. }
  907. }
  908. BitmapContinueCreatePDUList.EmptyList();
  909. }
  910. //
  911. //
  912. // Function: CreateColoredIcon
  913. //
  914. // Purpose: Create an icon of the correct color for this pointer.
  915. //
  916. //
  917. HICON BitmapObj::CreateColoredIcon(COLORREF color, LPBITMAPINFOHEADER lpbInfo, LPBYTE pMaskBits)
  918. {
  919. HICON hColoredIcon = NULL;
  920. HBRUSH hBrush = NULL;
  921. HBRUSH hOldBrush;
  922. HBITMAP hImage = NULL;
  923. HBITMAP hOldBitmap;
  924. HBITMAP hMask = NULL;
  925. COLOREDICON *pColoredIcon;
  926. ICONINFO ii;
  927. UINT i;
  928. LPSTR pBits;
  929. LPBITMAPINFOHEADER lpbi;
  930. BYTE swapByte;
  931. color = SET_PALETTERGB(color);
  932. MLZ_EntryOut(ZONE_FUNCTION, "RemotePointerObject::CreateColoredIcon");
  933. //
  934. // Create the mask for the icon with the data sent through T126
  935. //
  936. if(pMaskBits && lpbInfo)
  937. {
  938. hMask = CreateBitmap(lpbInfo->biWidth, lpbInfo->biHeight, 1, 1, m_lpTransparencyMask);
  939. }
  940. //
  941. // Create the local mask
  942. //
  943. else
  944. {
  945. // Load the mask bitmap
  946. hMask = ::LoadBitmap(g_hInstance, MAKEINTRESOURCE(REMOTEPOINTERANDMASK));
  947. if (!hMask)
  948. {
  949. TRACE_MSG(("Could not load mask bitmap"));
  950. goto CreateIconCleanup;
  951. }
  952. }
  953. //
  954. // Create a bitmap with the data that sent through T126
  955. //
  956. if(lpbInfo)
  957. {
  958. VOID *ppvBits;
  959. hImage = CreateDIBSection(m_hMemDC, (LPBITMAPINFO)lpbInfo, DIB_RGB_COLORS, &ppvBits, NULL, 0);
  960. if(!ppvBits)
  961. {
  962. TRACE_MSG(("CreateColoredIcon failed calling CreateDIBSection error = %d", GetLastError()));
  963. goto CreateIconCleanup;
  964. }
  965. pBits = DIB_Bits(lpbInfo);
  966. ::GetDIBits(m_hMemDC, hImage, 0, (WORD) lpbInfo->biHeight, NULL,(LPBITMAPINFO)lpbInfo, DIB_RGB_COLORS);
  967. memcpy(ppvBits, pBits, lpbInfo->biSizeImage);
  968. if(!hMask)
  969. {
  970. hMask = CreateBitmap(lpbInfo->biWidth, lpbInfo->biHeight, 1, 1, NULL);
  971. }
  972. }
  973. //
  974. // Create a local bitmap
  975. //
  976. else
  977. {
  978. // Load the image bitmap
  979. hImage = ::LoadBitmap(g_hInstance, MAKEINTRESOURCE(REMOTEPOINTERXORDATA));
  980. if (!hImage)
  981. {
  982. TRACE_MSG(("Could not load pointer bitmap"));
  983. goto CreateIconCleanup;
  984. }
  985. hBrush = ::CreateSolidBrush(color);
  986. if (!hBrush)
  987. {
  988. TRACE_MSG(("Couldn't create color brush"));
  989. goto CreateIconCleanup;
  990. }
  991. // Select in the icon color
  992. hOldBrush = SelectBrush(m_hMemDC, hBrush);
  993. // Select the image bitmap into the memory DC
  994. hOldBitmap = SelectBitmap(m_hMemDC, hImage);
  995. if(!hOldBitmap)
  996. {
  997. ERROR_OUT(("DeleteSavedBitmap - Could not select old bitmap"));
  998. }
  999. // Fill the image bitmap with color
  1000. ::FloodFill(m_hMemDC, ::GetSystemMetrics(SM_CXICON) / 2, ::GetSystemMetrics(SM_CYICON) / 2, RGB(0, 0, 0));
  1001. SelectBitmap(m_hMemDC, hOldBitmap);
  1002. SelectBrush(m_hMemDC, hOldBrush);
  1003. }
  1004. //
  1005. // Now use the image and mask bitmaps to create an icon
  1006. //
  1007. ii.fIcon = TRUE;
  1008. ii.xHotspot = 0;
  1009. ii.yHotspot = 0;
  1010. ii.hbmMask = hMask;
  1011. ii.hbmColor = hImage;
  1012. // Create a new icon from the data and mask
  1013. hColoredIcon = ::CreateIconIndirect(&ii);
  1014. //
  1015. // Create the internal format if we were created locally
  1016. //
  1017. if(m_lpbiImage == NULL)
  1018. {
  1019. m_lpbiImage = DIB_FromBitmap(hImage, NULL, FALSE, FALSE, TRUE);
  1020. }
  1021. if(m_lpTransparencyMask == NULL)
  1022. {
  1023. ChangedTransparencyMask();
  1024. lpbi = DIB_FromBitmap(hMask,NULL,FALSE, TRUE);
  1025. pBits = DIB_Bits(lpbi);
  1026. m_SizeOfTransparencyMask = lpbi->biSizeImage;
  1027. DBG_SAVE_FILE_LINE
  1028. m_lpTransparencyMask = new BYTE[m_SizeOfTransparencyMask];
  1029. memcpy(m_lpTransparencyMask, pBits, m_SizeOfTransparencyMask );
  1030. ::GlobalFree(lpbi);
  1031. }
  1032. if (m_lpbiImage == NULL)
  1033. {
  1034. ::Message(NULL, (UINT)IDS_MSG_CAPTION, (UINT)IDS_CANTGETBMP, (UINT)MB_OK );
  1035. }
  1036. else
  1037. {
  1038. m_bitmapSize.x = m_lpbiImage->biWidth;
  1039. m_bitmapSize.y = m_lpbiImage->biHeight;
  1040. RECT rect;
  1041. GetBoundsRect(&rect);
  1042. // Calculate the bounding rectangle from the size of the bitmap
  1043. rect.right = rect.left + m_lpbiImage->biWidth;
  1044. rect.bottom = rect.top + m_lpbiImage->biHeight;
  1045. SetRect(&rect);
  1046. SetAnchorPoint(rect.left, rect.top);
  1047. }
  1048. CreateIconCleanup:
  1049. // Free the image bitmap
  1050. if (hImage != NULL)
  1051. {
  1052. ::DeleteBitmap(hImage);
  1053. }
  1054. // Free the mask bitmap
  1055. if (hMask != NULL)
  1056. {
  1057. ::DeleteBitmap(hMask);
  1058. }
  1059. if (hBrush != NULL)
  1060. {
  1061. ::DeleteBrush(hBrush);
  1062. }
  1063. m_hIcon = hColoredIcon;
  1064. return(hColoredIcon);
  1065. }
  1066. //
  1067. //
  1068. // Function: BitmapObj::CreateSaveBitmap()
  1069. //
  1070. // Purpose: Create a bitmap for saving the bits under the pointer.
  1071. //
  1072. //
  1073. void BitmapObj::CreateSaveBitmap()
  1074. {
  1075. MLZ_EntryOut(ZONE_FUNCTION, "BitmapObj::CreateSaveBitmap");
  1076. // If we already have a save bitmap, exit immediately
  1077. if (m_hSaveBitmap != NULL)
  1078. {
  1079. TRACE_MSG(("Already have save bitmap"));
  1080. return;
  1081. }
  1082. // Create a bitmap to save the bits under the icon. This bitmap is
  1083. // created with space for building the new screen image before
  1084. // blitting it to the screen.
  1085. RECT rect;
  1086. RECT rcVis;
  1087. POINT point;
  1088. POINT delta;
  1089. HDC hDC = NULL;
  1090. g_pDraw->GetVisibleRect(&rcVis);
  1091. GetRect(&rect);
  1092. delta.x = rect.right - rect.left;
  1093. delta.y = rect.bottom - rect.top;
  1094. point.x = rect.left - rcVis.left;
  1095. point.y = rect.top - rcVis.top;
  1096. ClientToScreen (g_pDraw->m_hwnd, &point);
  1097. rect.left = point.x;
  1098. rect.top = point.y;
  1099. rect.right = rect.left + delta.x;
  1100. rect.bottom = rect.top + delta.y;
  1101. //
  1102. // Create the bitmap
  1103. //
  1104. m_hSaveBitmap = FromScreenAreaBmp(&rect);
  1105. }
  1106. //
  1107. //
  1108. // Function: BitmapObj::Undraw()
  1109. //
  1110. // Purpose: Draw the marker object
  1111. //
  1112. //
  1113. void BitmapObj::UnDraw(void)
  1114. {
  1115. if(GraphicTool() == TOOLTYPE_REMOTEPOINTER)
  1116. {
  1117. // Create the save bitmap if necessary
  1118. CreateSaveBitmap();
  1119. //
  1120. // Select the saved area
  1121. //
  1122. if(m_hSaveBitmap)
  1123. {
  1124. m_hOldBitmap = SelectBitmap(m_hMemDC, m_hSaveBitmap);
  1125. if(!m_hOldBitmap)
  1126. {
  1127. ERROR_OUT(("DeleteSavedBitmap - Could not select old bitmap"));
  1128. }
  1129. }
  1130. // Copy the saved bits onto the screen
  1131. UndrawScreen();
  1132. }
  1133. else
  1134. {
  1135. RECT rect;
  1136. GetBoundsRect(&rect);
  1137. g_pDraw->InvalidateSurfaceRect(&rect,TRUE);
  1138. }
  1139. }
  1140. //
  1141. //
  1142. // Function: BitmapObj::UndrawScreen()
  1143. //
  1144. // Purpose: Copy the saved bits under the pointer to the screen.
  1145. //
  1146. //
  1147. BOOL BitmapObj::UndrawScreen()
  1148. {
  1149. BOOL bResult = FALSE;
  1150. RECT rcUpdate;
  1151. MLZ_EntryOut(ZONE_FUNCTION, "DCWbGraphicPointer::UndrawScreen");
  1152. GetRect(&rcUpdate);
  1153. // We are undrawing - copy the saved bits to the DC passed
  1154. bResult = ::BitBlt(g_pDraw->m_hDCCached, rcUpdate.left, rcUpdate.top,
  1155. rcUpdate.right - rcUpdate.left, rcUpdate.bottom - rcUpdate.top,
  1156. m_hMemDC, 0, 0, SRCCOPY);
  1157. if (!bResult)
  1158. {
  1159. WARNING_OUT(("UndrawScreen - Could not copy from bitmap"));
  1160. }
  1161. else
  1162. {
  1163. DeleteSavedBitmap();
  1164. }
  1165. return(bResult);
  1166. }
  1167. void BitmapObj::DeleteSavedBitmap(void)
  1168. {
  1169. // Restore the original bitmap to the memory DC
  1170. if (m_hOldBitmap != NULL)
  1171. {
  1172. if(!SelectBitmap(m_hMemDC, m_hOldBitmap))
  1173. {
  1174. ERROR_OUT(("DeleteSavedBitmap - Could not select old bitmap"));
  1175. }
  1176. // if(!DeleteBitmap(m_hOldBitmap))
  1177. // {
  1178. // ERROR_OUT(("DeleteSavedBitmap - Could not delete old bitmap"));
  1179. // }
  1180. m_hOldBitmap = NULL;
  1181. }
  1182. if (m_hSaveBitmap != NULL)
  1183. {
  1184. if(!DeleteBitmap(m_hSaveBitmap))
  1185. {
  1186. ERROR_OUT(("DeleteSavedBitmap - Could not delete bitmap"));
  1187. }
  1188. m_hSaveBitmap = NULL;
  1189. }
  1190. }
  1191.