Leaked source code of windows server 2003
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.

1459 lines
34 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. if(lpbi8 == NULL)
  515. {
  516. TRACE_MSG(("Failed to convert bitmap"));
  517. ::PostMessage(g_pMain->m_hwnd, WM_USER_DISPLAY_ERROR, WBFE_RC_WINDOWS, 0);
  518. delete [] sipdu;
  519. return;
  520. }
  521. pDIB_bits = (LPSTR)lpbi8;
  522. sizeOfBmpData = DIB_TotalLength(lpbi8);
  523. //
  524. // Sending data
  525. //
  526. BOOL bMoreToFollow = FALSE;
  527. DWORD length = sizeOfBmpData;
  528. pCreatePDU->bitmapData.bit_mask = 0;
  529. if(sizeOfBmpData > MAX_BITMAP_DATA)
  530. {
  531. length = MAX_BITMAP_DATA;
  532. bMoreToFollow = TRUE;
  533. }
  534. pCreatePDU->moreToFollow = (ASN1bool_t)bMoreToFollow;
  535. //
  536. // Pass the bitmap info
  537. //
  538. pCreatePDU->bit_mask |= BitmapCreatePDU_nonStandardParameters_present;
  539. CreateNonStandard24BitBitmap(&sipdu->u.bitmapCreatePDU);
  540. pCreatePDU->nonStandardParameters->value.data.length = length;
  541. pCreatePDU->nonStandardParameters->value.data.value = (ASN1octet_t *)pDIB_bits;
  542. //
  543. // We are not passing it into the data field
  544. //
  545. pCreatePDU->bitmapData.bit_mask = 0;
  546. pCreatePDU->bitmapData.data.length = 1;
  547. pCreatePDUList->AddTail(sipdu);
  548. BitmapCreateContinuePDU * pCreateContinuePDU;
  549. while(bMoreToFollow)
  550. {
  551. //
  552. // Advance the pointer
  553. //
  554. pDIB_bits += MAX_BITMAP_DATA;
  555. sizeOfBmpData-= MAX_BITMAP_DATA;
  556. if(sizeOfBmpData > MAX_BITMAP_DATA)
  557. {
  558. length = MAX_BITMAP_DATA;
  559. }
  560. else
  561. {
  562. length = sizeOfBmpData;
  563. bMoreToFollow = FALSE;
  564. }
  565. //
  566. // Create a new BitmapCreateContinuePDU
  567. //
  568. sipdu = NULL;
  569. DBG_SAVE_FILE_LINE
  570. sipdu = (SIPDU *) new BYTE[sizeof(SIPDU)];
  571. if(!sipdu)
  572. {
  573. TRACE_MSG(("Failed to create sipdu"));
  574. ::PostMessage(g_pMain->m_hwnd, WM_USER_DISPLAY_ERROR, WBFE_RC_WINDOWS, 0);
  575. return;
  576. }
  577. sipdu->choice = bitmapCreateContinuePDU_chosen;
  578. pCreateContinuePDU = &sipdu->u.bitmapCreateContinuePDU;
  579. pCreateContinuePDU->bit_mask = 0;
  580. pCreateContinuePDU->nonStandardParameters = NULL;
  581. //
  582. // Pass the bitmap Handle
  583. //
  584. pCreateContinuePDU->bitmapHandle = GetThisObjectHandle();
  585. //
  586. // Pass the data
  587. //
  588. pCreateContinuePDU->bit_mask |= BitmapCreateContinuePDU_nonStandardParameters_present;
  589. //
  590. // Pass the bitmap info
  591. //
  592. DBG_SAVE_FILE_LINE
  593. pCreateContinuePDU->nonStandardParameters = new BitmapCreateContinuePDU_nonStandardParameters;
  594. pCreateContinuePDU->nonStandardParameters->next = NULL;
  595. CreateNonStandardPDU(&pCreateContinuePDU->nonStandardParameters->value, NonStandard24BitBitmapID);
  596. pCreateContinuePDU->nonStandardParameters->value.data.length = length;
  597. pCreateContinuePDU->nonStandardParameters->value.data.value = (ASN1octet_t *)pDIB_bits;
  598. //
  599. // We are not passing it into the data field
  600. //
  601. pCreateContinuePDU->bitmapData.bit_mask = 0;
  602. pCreateContinuePDU->bitmapData.data.length = 1;
  603. pCreateContinuePDU->moreToFollow = (ASN1bool_t) bMoreToFollow;
  604. pCreatePDUList->AddTail(sipdu);
  605. }
  606. if(hbmp)
  607. {
  608. DeleteObject(hbmp);
  609. }
  610. if(hdc)
  611. {
  612. ReleaseDC(NULL, hdc);
  613. }
  614. }
  615. void BitmapObj::CreateBitmapEditPDU(BitmapEditPDU *pEditPDU)
  616. {
  617. pEditPDU->bit_mask = (ASN1uint16_t) GetPresentAttribs();
  618. //
  619. // Pass the anchor point
  620. //
  621. if(HasAnchorPointChanged())
  622. {
  623. POINT point;
  624. GetAnchorPoint(&point);
  625. pEditPDU->anchorPointEdit.xCoordinate = point.x;
  626. pEditPDU->anchorPointEdit.yCoordinate = point.y;
  627. }
  628. //
  629. // JOSEF Pass Region of interest (FEATURE)
  630. //
  631. //
  632. // JOSEF Pass scaling (FEATURE)
  633. //
  634. //
  635. // Pass all the changed attributes, if any.
  636. //
  637. pEditPDU->attributeEdits = NULL;
  638. if(pEditPDU->bit_mask & BitmapEditPDU_attributeEdits_present)
  639. {
  640. SetBitmapAttrib((PBitmapCreatePDU_attributes *)&pEditPDU->attributeEdits);
  641. }
  642. pEditPDU->bitmapHandle = GetThisObjectHandle();
  643. }
  644. void BitmapObj::CreateBitmapDeletePDU(BitmapDeletePDU *pDeletePDU)
  645. {
  646. pDeletePDU->bit_mask = 0;
  647. pDeletePDU->bitmapHandle = GetThisObjectHandle();
  648. }
  649. void BitmapObj::AllocateAttrib(PBitmapCreatePDU_attributes *pAttributes)
  650. {
  651. DBG_SAVE_FILE_LINE
  652. PBitmapCreatePDU_attributes pAttrib = (PBitmapCreatePDU_attributes)new BYTE[sizeof(BitmapCreatePDU_attributes)];
  653. if(*pAttributes == NULL)
  654. {
  655. *pAttributes = pAttrib;
  656. pAttrib->next = NULL;
  657. }
  658. else
  659. {
  660. ((PBitmapCreatePDU_attributes)pAttrib)->next = *pAttributes;
  661. *pAttributes = pAttrib;
  662. }
  663. }
  664. void BitmapObj::SetBitmapAttrib(PBitmapCreatePDU_attributes *pattributes)
  665. {
  666. PBitmapCreatePDU_attributes attributes = NULL;
  667. //
  668. // Do the viewState
  669. //
  670. if(HasViewStateChanged())
  671. {
  672. AllocateAttrib(&attributes);
  673. attributes->value.choice = BitmapAttribute_viewState_chosen;
  674. attributes->value.u.viewState.choice = (ASN1choice_t)GetViewState();
  675. }
  676. //
  677. // Do the zOrder
  678. //
  679. if(HasZOrderChanged())
  680. {
  681. AllocateAttrib(&attributes);
  682. attributes->value.choice = BitmapAttribute_zOrder_chosen;
  683. attributes->value.u.zOrder = GetZOrder();
  684. }
  685. //
  686. // Do the Transparency
  687. //
  688. if(HasTransparencyMaskChanged())
  689. {
  690. AllocateAttrib(&attributes);
  691. attributes->value.choice = BitmapAttribute_transparencyMask_chosen;
  692. attributes->value.u.transparencyMask.bit_mask = 0;
  693. attributes->value.u.transparencyMask.bitMask.choice = uncompressed_chosen;
  694. attributes->value.u.transparencyMask.bitMask.u.uncompressed.length = m_SizeOfTransparencyMask;
  695. attributes->value.u.transparencyMask.bitMask.u.uncompressed.value = m_lpTransparencyMask;
  696. }
  697. //
  698. // End of attributes
  699. //
  700. *pattributes = attributes;
  701. }
  702. void BitmapObj::Draw(HDC hDC, BOOL bForcedDraw, BOOL bPrinting)
  703. {
  704. if(!bPrinting)
  705. {
  706. //
  707. // Don't draw anything if we don't belong in this workspace
  708. //
  709. if(GetWorkspaceHandle() != g_pCurrentWorkspace->GetThisObjectHandle())
  710. {
  711. return;
  712. }
  713. }
  714. RECT clipBox;
  715. RECT rect;
  716. GetRect(&rect);
  717. if(hDC == NULL)
  718. {
  719. hDC = g_pDraw->m_hDCCached;
  720. }
  721. MLZ_EntryOut(ZONE_FUNCTION, "BitmapObj::Draw");
  722. // Only draw anything if the bounding rectangle intersects
  723. // the current clip box.
  724. if (::GetClipBox(hDC, &clipBox) == ERROR)
  725. {
  726. WARNING_OUT(("Failed to get clip box"));
  727. }
  728. else if (!::IntersectRect(&clipBox, &clipBox, &rect))
  729. {
  730. TRACE_MSG(("No clip/bounds intersection"));
  731. return;
  732. }
  733. if(m_ToolType == TOOLTYPE_FILLEDBOX)
  734. {
  735. if(m_fMoreToFollow)
  736. {
  737. return;
  738. }
  739. // Set the stretch mode to be used so that scan lines are deleted
  740. // rather than combined. This will tend to preserve color better.
  741. int iOldStretchMode = ::SetStretchBltMode(hDC, STRETCH_DELETESCANS);
  742. // Draw the bitmap
  743. ::StretchDIBits(hDC,
  744. rect.left,
  745. rect.top,
  746. rect.right - rect.left,
  747. rect.bottom - rect.top,
  748. 0,
  749. 0,
  750. (UINT) m_lpbiImage->biWidth,
  751. (UINT) m_lpbiImage->biHeight,
  752. (VOID FAR *) DIB_Bits(m_lpbiImage),
  753. (LPBITMAPINFO)m_lpbiImage,
  754. DIB_RGB_COLORS,
  755. SRCCOPY);
  756. // Restore the stretch mode
  757. ::SetStretchBltMode(hDC, iOldStretchMode);
  758. }
  759. else
  760. {
  761. // Create the save bitmap if necessary
  762. CreateSaveBitmap();
  763. // Draw the icon
  764. ::DrawIcon(hDC, rect.left, rect.top, m_hIcon);
  765. }
  766. }
  767. //
  768. //
  769. // Function: BitmapObj::::FromScreenArea
  770. //
  771. // Purpose: Set the content of the object from an area of the screen
  772. //
  773. //
  774. void BitmapObj::FromScreenArea(LPCRECT lprcScreen)
  775. {
  776. m_lpbiImage = DIB_FromScreenArea(lprcScreen);
  777. if (m_lpbiImage == NULL)
  778. {
  779. ::Message(NULL, (UINT)IDS_MSG_CAPTION, (UINT)IDS_CANTGETBMP, (UINT)MB_OK );
  780. }
  781. else
  782. {
  783. m_bitmapSize.x = m_lpbiImage->biWidth;
  784. m_bitmapSize.y = m_lpbiImage->biHeight;
  785. RECT rect;
  786. GetBoundsRect(&rect);
  787. // Calculate the bounding rectangle from the size of the bitmap
  788. rect.right = rect.left + m_lpbiImage->biWidth;
  789. rect.bottom = rect.top + m_lpbiImage->biHeight;
  790. SetRect(&rect);
  791. }
  792. }
  793. UINT GetBitmapDestinationAddress(BitmapDestinationAddress *destinationAddress, PUINT workspaceHandle, PUINT planeID)
  794. {
  795. UINT toolType = TOOLTYPE_FILLEDBOX;
  796. //
  797. // Get the destination address
  798. //
  799. switch(destinationAddress->choice)
  800. {
  801. case(BitmapDestinationAddress_softCopyImagePlane_chosen):
  802. {
  803. *workspaceHandle = (destinationAddress->u.softCopyImagePlane.workspaceHandle);
  804. *planeID = (destinationAddress->u.softCopyImagePlane.plane);
  805. break;
  806. }
  807. case(BitmapDestinationAddress_softCopyAnnotationPlane_chosen):
  808. {
  809. *workspaceHandle = (destinationAddress->u.softCopyAnnotationPlane.workspaceHandle);
  810. *planeID = (destinationAddress->u.softCopyAnnotationPlane.plane);
  811. break;
  812. }
  813. case(softCopyPointerPlane_chosen):
  814. {
  815. *workspaceHandle = (destinationAddress->u.softCopyPointerPlane.workspaceHandle);
  816. *planeID = (0);
  817. toolType = TOOLTYPE_REMOTEPOINTER;
  818. break;
  819. }
  820. // case(BitmapDestinationAddress_nonStandardDestination_chosen):
  821. // {
  822. // break;
  823. // }
  824. default:
  825. ERROR_OUT(("Invalid destinationAddress"));
  826. break;
  827. }
  828. return toolType;
  829. }
  830. //
  831. // UI Edited the Bitmap Object
  832. //
  833. void BitmapObj::OnObjectEdit(void)
  834. {
  835. g_bContentsChanged = TRUE;
  836. SIPDU *sipdu = NULL;
  837. DBG_SAVE_FILE_LINE
  838. sipdu = (SIPDU *) new BYTE[sizeof(SIPDU)];
  839. if(sipdu)
  840. {
  841. sipdu->choice = bitmapEditPDU_chosen;
  842. CreateBitmapEditPDU(&sipdu->u.bitmapEditPDU);
  843. T120Error rc = SendT126PDU(sipdu);
  844. if(rc == T120_NO_ERROR)
  845. {
  846. SIPDUCleanUp(sipdu);
  847. }
  848. }
  849. else
  850. {
  851. TRACE_MSG(("Failed to create sipdu"));
  852. ::PostMessage(g_pMain->m_hwnd, WM_USER_DISPLAY_ERROR, WBFE_RC_WINDOWS, 0);
  853. }
  854. }
  855. //
  856. // UI Deleted the Bitmap Object
  857. //
  858. void BitmapObj::OnObjectDelete(void)
  859. {
  860. SIPDU *sipdu = NULL;
  861. DBG_SAVE_FILE_LINE
  862. sipdu = (SIPDU *) new BYTE[sizeof(SIPDU)];
  863. if(sipdu)
  864. {
  865. sipdu->choice = bitmapDeletePDU_chosen;
  866. CreateBitmapDeletePDU(&sipdu->u.bitmapDeletePDU);
  867. T120Error rc = SendT126PDU(sipdu);
  868. if(rc == T120_NO_ERROR)
  869. {
  870. SIPDUCleanUp(sipdu);
  871. }
  872. }
  873. else
  874. {
  875. TRACE_MSG(("Failed to create sipdu"));
  876. ::PostMessage(g_pMain->m_hwnd, WM_USER_DISPLAY_ERROR, WBFE_RC_WINDOWS, 0);
  877. }
  878. }
  879. void BitmapObj::GetEncodedCreatePDU(ASN1_BUF *pBuf)
  880. {
  881. pBuf->length = DIB_TotalLength(m_lpbiImage);
  882. pBuf->value = (PBYTE)m_lpbiImage;
  883. }
  884. //
  885. // UI Created a new Bitmap Object
  886. //
  887. void BitmapObj::SendNewObjectToT126Apps(void)
  888. {
  889. SIPDU *sipdu = NULL;
  890. CWBOBLIST BitmapContinueCreatePDUList;
  891. BitmapContinueCreatePDUList.EmptyList();
  892. CreateBitmapCreatePDU(&BitmapContinueCreatePDUList);
  893. T120Error rc = T120_NO_ERROR;
  894. WBPOSITION pos = BitmapContinueCreatePDUList.GetHeadPosition();
  895. while (pos != NULL)
  896. {
  897. sipdu = (SIPDU *) BitmapContinueCreatePDUList.GetNext(pos);
  898. TRACE_DEBUG(("Sending Bitmap >> Bitmap handle = %d", sipdu->u.bitmapCreatePDU.bitmapHandle ));
  899. if(g_bSavingFile && GraphicTool() == TOOLTYPE_REMOTEPOINTER)
  900. {
  901. ; // Don't send Remote pointers to disk
  902. }
  903. else
  904. {
  905. if(!m_fMoreToFollow)
  906. {
  907. rc = SendT126PDU(sipdu);
  908. }
  909. }
  910. if(rc == T120_NO_ERROR)
  911. {
  912. SIPDUCleanUp(sipdu);
  913. }
  914. }
  915. BitmapContinueCreatePDUList.EmptyList();
  916. }
  917. //
  918. //
  919. // Function: CreateColoredIcon
  920. //
  921. // Purpose: Create an icon of the correct color for this pointer.
  922. //
  923. //
  924. HICON BitmapObj::CreateColoredIcon(COLORREF color, LPBITMAPINFOHEADER lpbInfo, LPBYTE pMaskBits)
  925. {
  926. HICON hColoredIcon = NULL;
  927. HBRUSH hBrush = NULL;
  928. HBRUSH hOldBrush;
  929. HBITMAP hImage = NULL;
  930. HBITMAP hOldBitmap;
  931. HBITMAP hMask = NULL;
  932. COLOREDICON *pColoredIcon;
  933. ICONINFO ii;
  934. UINT i;
  935. LPSTR pBits;
  936. LPBITMAPINFOHEADER lpbi;
  937. BYTE swapByte;
  938. color = SET_PALETTERGB(color);
  939. MLZ_EntryOut(ZONE_FUNCTION, "RemotePointerObject::CreateColoredIcon");
  940. //
  941. // Create the mask for the icon with the data sent through T126
  942. //
  943. if(pMaskBits && lpbInfo)
  944. {
  945. hMask = CreateBitmap(lpbInfo->biWidth, lpbInfo->biHeight, 1, 1, m_lpTransparencyMask);
  946. }
  947. //
  948. // Create the local mask
  949. //
  950. else
  951. {
  952. // Load the mask bitmap
  953. hMask = ::LoadBitmap(g_hInstance, MAKEINTRESOURCE(REMOTEPOINTERANDMASK));
  954. if (!hMask)
  955. {
  956. TRACE_MSG(("Could not load mask bitmap"));
  957. goto CreateIconCleanup;
  958. }
  959. }
  960. //
  961. // Create a bitmap with the data that sent through T126
  962. //
  963. if(lpbInfo)
  964. {
  965. VOID *ppvBits;
  966. hImage = CreateDIBSection(m_hMemDC, (LPBITMAPINFO)lpbInfo, DIB_RGB_COLORS, &ppvBits, NULL, 0);
  967. if(!ppvBits)
  968. {
  969. TRACE_MSG(("CreateColoredIcon failed calling CreateDIBSection error = %d", GetLastError()));
  970. goto CreateIconCleanup;
  971. }
  972. pBits = DIB_Bits(lpbInfo);
  973. ::GetDIBits(m_hMemDC, hImage, 0, (WORD) lpbInfo->biHeight, NULL,(LPBITMAPINFO)lpbInfo, DIB_RGB_COLORS);
  974. memcpy(ppvBits, pBits, lpbInfo->biSizeImage);
  975. if(!hMask)
  976. {
  977. hMask = CreateBitmap(lpbInfo->biWidth, lpbInfo->biHeight, 1, 1, NULL);
  978. }
  979. }
  980. //
  981. // Create a local bitmap
  982. //
  983. else
  984. {
  985. // Load the image bitmap
  986. hImage = ::LoadBitmap(g_hInstance, MAKEINTRESOURCE(REMOTEPOINTERXORDATA));
  987. if (!hImage)
  988. {
  989. TRACE_MSG(("Could not load pointer bitmap"));
  990. goto CreateIconCleanup;
  991. }
  992. hBrush = ::CreateSolidBrush(color);
  993. if (!hBrush)
  994. {
  995. TRACE_MSG(("Couldn't create color brush"));
  996. goto CreateIconCleanup;
  997. }
  998. // Select in the icon color
  999. hOldBrush = SelectBrush(m_hMemDC, hBrush);
  1000. // Select the image bitmap into the memory DC
  1001. hOldBitmap = SelectBitmap(m_hMemDC, hImage);
  1002. if(!hOldBitmap)
  1003. {
  1004. ERROR_OUT(("DeleteSavedBitmap - Could not select old bitmap"));
  1005. }
  1006. // Fill the image bitmap with color
  1007. ::FloodFill(m_hMemDC, ::GetSystemMetrics(SM_CXICON) / 2, ::GetSystemMetrics(SM_CYICON) / 2, RGB(0, 0, 0));
  1008. SelectBitmap(m_hMemDC, hOldBitmap);
  1009. SelectBrush(m_hMemDC, hOldBrush);
  1010. }
  1011. //
  1012. // Now use the image and mask bitmaps to create an icon
  1013. //
  1014. ii.fIcon = TRUE;
  1015. ii.xHotspot = 0;
  1016. ii.yHotspot = 0;
  1017. ii.hbmMask = hMask;
  1018. ii.hbmColor = hImage;
  1019. // Create a new icon from the data and mask
  1020. hColoredIcon = ::CreateIconIndirect(&ii);
  1021. //
  1022. // Create the internal format if we were created locally
  1023. //
  1024. if(m_lpbiImage == NULL)
  1025. {
  1026. m_lpbiImage = DIB_FromBitmap(hImage, NULL, FALSE, FALSE, TRUE);
  1027. }
  1028. if(m_lpTransparencyMask == NULL)
  1029. {
  1030. ChangedTransparencyMask();
  1031. lpbi = DIB_FromBitmap(hMask,NULL,FALSE, TRUE);
  1032. pBits = DIB_Bits(lpbi);
  1033. m_SizeOfTransparencyMask = lpbi->biSizeImage;
  1034. DBG_SAVE_FILE_LINE
  1035. m_lpTransparencyMask = new BYTE[m_SizeOfTransparencyMask];
  1036. memcpy(m_lpTransparencyMask, pBits, m_SizeOfTransparencyMask );
  1037. ::GlobalFree(lpbi);
  1038. }
  1039. if (m_lpbiImage == NULL)
  1040. {
  1041. ::Message(NULL, (UINT)IDS_MSG_CAPTION, (UINT)IDS_CANTGETBMP, (UINT)MB_OK );
  1042. }
  1043. else
  1044. {
  1045. m_bitmapSize.x = m_lpbiImage->biWidth;
  1046. m_bitmapSize.y = m_lpbiImage->biHeight;
  1047. RECT rect;
  1048. GetBoundsRect(&rect);
  1049. // Calculate the bounding rectangle from the size of the bitmap
  1050. rect.right = rect.left + m_lpbiImage->biWidth;
  1051. rect.bottom = rect.top + m_lpbiImage->biHeight;
  1052. SetRect(&rect);
  1053. SetAnchorPoint(rect.left, rect.top);
  1054. }
  1055. CreateIconCleanup:
  1056. // Free the image bitmap
  1057. if (hImage != NULL)
  1058. {
  1059. ::DeleteBitmap(hImage);
  1060. }
  1061. // Free the mask bitmap
  1062. if (hMask != NULL)
  1063. {
  1064. ::DeleteBitmap(hMask);
  1065. }
  1066. if (hBrush != NULL)
  1067. {
  1068. ::DeleteBrush(hBrush);
  1069. }
  1070. m_hIcon = hColoredIcon;
  1071. return(hColoredIcon);
  1072. }
  1073. //
  1074. //
  1075. // Function: BitmapObj::CreateSaveBitmap()
  1076. //
  1077. // Purpose: Create a bitmap for saving the bits under the pointer.
  1078. //
  1079. //
  1080. void BitmapObj::CreateSaveBitmap()
  1081. {
  1082. MLZ_EntryOut(ZONE_FUNCTION, "BitmapObj::CreateSaveBitmap");
  1083. // If we already have a save bitmap, exit immediately
  1084. if (m_hSaveBitmap != NULL)
  1085. {
  1086. TRACE_MSG(("Already have save bitmap"));
  1087. return;
  1088. }
  1089. // Create a bitmap to save the bits under the icon. This bitmap is
  1090. // created with space for building the new screen image before
  1091. // blitting it to the screen.
  1092. RECT rect;
  1093. RECT rcVis;
  1094. POINT point;
  1095. POINT delta;
  1096. HDC hDC = NULL;
  1097. g_pDraw->GetVisibleRect(&rcVis);
  1098. GetRect(&rect);
  1099. delta.x = rect.right - rect.left;
  1100. delta.y = rect.bottom - rect.top;
  1101. point.x = rect.left - rcVis.left;
  1102. point.y = rect.top - rcVis.top;
  1103. ClientToScreen (g_pDraw->m_hwnd, &point);
  1104. rect.left = point.x;
  1105. rect.top = point.y;
  1106. rect.right = rect.left + delta.x;
  1107. rect.bottom = rect.top + delta.y;
  1108. //
  1109. // Create the bitmap
  1110. //
  1111. m_hSaveBitmap = FromScreenAreaBmp(&rect);
  1112. }
  1113. //
  1114. //
  1115. // Function: BitmapObj::Undraw()
  1116. //
  1117. // Purpose: Draw the marker object
  1118. //
  1119. //
  1120. void BitmapObj::UnDraw(void)
  1121. {
  1122. if(GraphicTool() == TOOLTYPE_REMOTEPOINTER)
  1123. {
  1124. // Create the save bitmap if necessary
  1125. CreateSaveBitmap();
  1126. //
  1127. // Select the saved area
  1128. //
  1129. if(m_hSaveBitmap)
  1130. {
  1131. m_hOldBitmap = SelectBitmap(m_hMemDC, m_hSaveBitmap);
  1132. if(!m_hOldBitmap)
  1133. {
  1134. ERROR_OUT(("DeleteSavedBitmap - Could not select old bitmap"));
  1135. }
  1136. }
  1137. // Copy the saved bits onto the screen
  1138. UndrawScreen();
  1139. }
  1140. else
  1141. {
  1142. RECT rect;
  1143. GetBoundsRect(&rect);
  1144. g_pDraw->InvalidateSurfaceRect(&rect,TRUE);
  1145. }
  1146. }
  1147. //
  1148. //
  1149. // Function: BitmapObj::UndrawScreen()
  1150. //
  1151. // Purpose: Copy the saved bits under the pointer to the screen.
  1152. //
  1153. //
  1154. BOOL BitmapObj::UndrawScreen()
  1155. {
  1156. BOOL bResult = FALSE;
  1157. RECT rcUpdate;
  1158. MLZ_EntryOut(ZONE_FUNCTION, "DCWbGraphicPointer::UndrawScreen");
  1159. GetRect(&rcUpdate);
  1160. // We are undrawing - copy the saved bits to the DC passed
  1161. bResult = ::BitBlt(g_pDraw->m_hDCCached, rcUpdate.left, rcUpdate.top,
  1162. rcUpdate.right - rcUpdate.left, rcUpdate.bottom - rcUpdate.top,
  1163. m_hMemDC, 0, 0, SRCCOPY);
  1164. if (!bResult)
  1165. {
  1166. WARNING_OUT(("UndrawScreen - Could not copy from bitmap"));
  1167. }
  1168. else
  1169. {
  1170. DeleteSavedBitmap();
  1171. }
  1172. return(bResult);
  1173. }
  1174. void BitmapObj::DeleteSavedBitmap(void)
  1175. {
  1176. // Restore the original bitmap to the memory DC
  1177. if (m_hOldBitmap != NULL)
  1178. {
  1179. if(!SelectBitmap(m_hMemDC, m_hOldBitmap))
  1180. {
  1181. ERROR_OUT(("DeleteSavedBitmap - Could not select old bitmap"));
  1182. }
  1183. // if(!DeleteBitmap(m_hOldBitmap))
  1184. // {
  1185. // ERROR_OUT(("DeleteSavedBitmap - Could not delete old bitmap"));
  1186. // }
  1187. m_hOldBitmap = NULL;
  1188. }
  1189. if (m_hSaveBitmap != NULL)
  1190. {
  1191. if(!DeleteBitmap(m_hSaveBitmap))
  1192. {
  1193. ERROR_OUT(("DeleteSavedBitmap - Could not delete bitmap"));
  1194. }
  1195. m_hSaveBitmap = NULL;
  1196. }
  1197. }
  1198.