示例#1
0
KTarga24::~KTarga24()
{
	ReleaseDDB();
	ReleaseDIB();

	if ( m_hFileMapping!=INVALID_HANDLE_VALUE )
		CloseHandle(m_hFileMapping);

	if ( m_hFile != INVALID_HANDLE_VALUE )
		CloseHandle(m_hFile);
}
示例#2
0
//+------------------------------------------------------------------------
//
//  Member:     COffScreenContext::~COffScreenContext()
//
//  Synopsis:   Release resources used by this class.
//
//-------------------------------------------------------------------------
COffScreenContext::~COffScreenContext()
{
	_fOffScreen = FALSE;
	if(_nSavedDC)
	{
		// restore the DC for the cached case
		Verify(RestoreDC(_hdcMem, _nSavedDC));
		_nSavedDC = 0;
	}

	// Put back a reasonable palette so ours can be deleted safely
	SelectPalette(_hdcMem, (HPALETTE)GetStockObject(DEFAULT_PALETTE), TRUE);

	if(_fUseDD)
	{
		ReleaseDDSurface();
	}
	else
	{
		ReleaseDDB();
	}
}
示例#3
0
BOOL KDIBSection::CreateDIBSection(HDC hDC, CONST BITMAPINFO * pBMI, UINT iUsage, HANDLE hSection, DWORD dwOffset)
{
	PVOID pBits = NULL;
	
	HBITMAP hBmp = ::CreateDIBSection(hDC, pBMI, iUsage, & pBits, hSection, dwOffset);

	int typ = GetObjectType(hBmp);
	int size = GetObject(hBmp, 0, NULL);

	if ( hBmp )
	{
		ReleaseDDB();	// free the previous object
		ReleaseDIB();	
		
		m_hBitmap = hBmp;	// Use DDB handle to store DIB Section Handle

//		MEMORY_BASIC_INFORMATION mbi;
//		VirtualQuery(pBits, & mbi, sizeof(mbi));

		int nColor = GetDIBColorCount(pBMI->bmiHeader);
		int nSize  = sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * nColor;
		
		BITMAPINFO * pDIB = (BITMAPINFO *) new BYTE[nSize];

		if ( pDIB==NULL )
			return FALSE;

		memcpy(pDIB, pBMI, nSize);	// copy header and color table

		AttachDIB(pDIB, (PBYTE) pBits, DIB_BMI_NEEDFREE);
		GetColorTable();
		return TRUE;
	}
	else
		return FALSE;
}