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