zgraphsection.cpp

来自「Symbian手机智能操作系统下的源码,图像查看软件,支持十几种图形格式.」· C++ 代码 · 共 73 行

CPP
73
字号
#include "zGraphSection.h"

//##ModelId=3FFA653C0135
zGraphSection::zGraphSection()
{
}


//##ModelId=3FFA653C0153
zGraphSection::~zGraphSection()
{
}

//##ModelId=3FFA80C601B5
bool zGraphSection::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;
}

//##ModelId=3FFA80CB01EE
UINT zGraphSection::GetColorTable()
{
	int width, height;

	if ( (this->m_nColorDepth>8) || ! Prepare(width, height) ) // create memory DC
		return 0;

	return GetDIBColorTable(m_hMemDC, 0, m_nClrUsed, m_pRGBQUAD);
}

//##ModelId=3FFA80CD010B
UINT zGraphSection::SetColorTable()
{
	int width, height;

	if ( (this->m_nColorDepth>8) || ! Prepare(width, height) ) // create memory DC
		return 0;

	return SetDIBColorTable(m_hMemDC, 0, m_nClrUsed, m_pRGBQUAD);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?