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.

75 lines
2.0 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: mtkbmp.cxx
  3. *
  4. * mtk bitmap
  5. *
  6. * Copyright (c) 1997 Microsoft Corporation
  7. *
  8. \**************************************************************************/
  9. #include "mtk.hxx"
  10. #include "mtkbmp.hxx"
  11. /******************************Public*Routine******************************\
  12. *
  13. \**************************************************************************/
  14. MTKBMP::MTKBMP( HDC hdcWinArg )
  15. {
  16. hBitmap = NULL;
  17. hdcWin = hdcWinArg;
  18. hdc = CreateCompatibleDC( hdcWin );
  19. size.width = size.height = 0;
  20. }
  21. MTKBMP::~MTKBMP()
  22. {
  23. if( hBitmap )
  24. DeleteObject( hBitmap );
  25. }
  26. BOOL
  27. MTKBMP::Resize( ISIZE *pSize )
  28. {
  29. if( (pSize->width <= 0) || (pSize->height <= 0) ) {
  30. SS_ERROR( "MTKBMP::Resize : Invalid size parameters\n" );
  31. return FALSE;
  32. }
  33. if( (pSize->width == size.width) && (pSize->height == size.height) )
  34. // Same size
  35. return TRUE;
  36. size = *pSize;
  37. PVOID pvBits; //mf: doesn't seem like we need this
  38. #if 1
  39. // Use system palette
  40. //mf: don't know why we have to use hdcWin here, but if I use hdc, get
  41. // error : 'not OBJ_DC'
  42. HBITMAP hbmNew =
  43. SSDIB_CreateCompatibleDIB(hdcWin, NULL, size.width, size.height, &pvBits);
  44. #else
  45. //mf: uhh, this never worked or something, right ?
  46. // Use log palette
  47. HBITMAP hbmNew = SSDIB_CreateCompatibleDIB(hdcWin,
  48. gpssPal ? gpssPal->hPal : NULL,
  49. size.width, size.height, &pvBits);
  50. #endif
  51. if (hbmNew)
  52. {
  53. if( hBitmap != NULL )
  54. {
  55. SelectObject( hdc, hBitmap );
  56. DeleteObject( hBitmap );
  57. }
  58. hBitmap = hbmNew;
  59. SelectObject( hdc, hBitmap );
  60. }
  61. return TRUE;
  62. }
  63. /******************************Public*Routine******************************\
  64. \**************************************************************************/