ImageFormatAggregator.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "stdafx.h"
  2. #include ".\ImageFormatAggregator.h"
  3. #include "Misc.h"
  4. #include "shared/Tokenizer.h"
  5. #include "BitmapHelper.h"
  6. CImageFormatAggregator::CImageFormatAggregator(BOOL horizontally)
  7. {
  8. m_horizontally = horizontally;
  9. }
  10. CImageFormatAggregator::~CImageFormatAggregator(void)
  11. {
  12. }
  13. bool CImageFormatAggregator::AddClip(LPVOID lpData, int nDataSize, int nPos, int nCount, UINT cfType)
  14. {
  15. HGLOBAL hGlobal = ::NewGlobalP(lpData, nDataSize);
  16. CClipFormat data(cfType, hGlobal);
  17. //m_images owns the data now
  18. data.AutoDeleteData(false);
  19. m_images.Add(data);
  20. return true;
  21. }
  22. HGLOBAL CImageFormatAggregator::GetHGlobal()
  23. {
  24. CBitmap bitmap;
  25. if (CBitmapHelper::GetCBitmap(m_images, CDC::FromHandle(GetDC(GetActiveWindow())), &bitmap, m_horizontally) == FALSE)
  26. {
  27. bitmap.DeleteObject();
  28. return NULL;
  29. }
  30. int count = m_images.GetCount();
  31. for (int i = 0; i < count; i++)
  32. {
  33. CClipFormat clip = m_images[i];
  34. clip.AutoDeleteData(true);
  35. clip.Free();
  36. }
  37. HPALETTE hPal = NULL;
  38. auto returnHGlobal = CBitmapHelper::hBitmapToDIB((HBITMAP)bitmap, BI_RGB, hPal);
  39. bitmap.DeleteObject();
  40. return returnHGlobal;
  41. }