⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zgraphsection.cpp

📁 Symbian手机智能操作系统下的源码,图像查看软件,支持十几种图形格式.
💻 CPP
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -