ClipFormatQListCtrl.cpp 1014 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "stdafx.h"
  2. #include "ClipFormatQListCtrl.h"
  3. #include "BitmapHelper.h"
  4. #include "CP_Main.h"
  5. CClipFormatQListCtrl::CClipFormatQListCtrl(void)
  6. {
  7. m_counter = 0;
  8. m_clipRow = -1;
  9. m_convertedToSmallImage = false;
  10. }
  11. CClipFormatQListCtrl::~CClipFormatQListCtrl(void)
  12. {
  13. }
  14. HGLOBAL CClipFormatQListCtrl::GetDibFittingToHeight(CDC *pDc, int height)
  15. {
  16. if(m_cfType != CF_DIB &&
  17. m_cfType != theApp.m_PNG_Format)
  18. {
  19. return NULL;
  20. }
  21. if(m_convertedToSmallImage)
  22. {
  23. return m_hgData;
  24. }
  25. m_convertedToSmallImage = true;
  26. CBitmap Bitmap;
  27. if( !CBitmapHelper::GetCBitmap(this, pDc, &Bitmap, height) )
  28. {
  29. Bitmap.DeleteObject();
  30. // the data is useless, so free it.
  31. this->Free();
  32. return FALSE;
  33. }
  34. this->m_autoDeleteData = true;
  35. // delete the large image data loaded from the db
  36. this->Free();
  37. this->m_autoDeleteData = false;
  38. //Convert the smaller bitmap back to a dib
  39. HPALETTE hPal = NULL;
  40. this->m_hgData = CBitmapHelper::hBitmapToDIB((HBITMAP)Bitmap, BI_RGB, hPal);
  41. return this->m_hgData;
  42. }