コード例 #1
0
int* IconSet::getIcon(int index)
{
	if (index < 0 || index > numIcons)
		throw string("Icon index not in range");

	BOOL result;
	//Clear the DC
	memset(pixels, 0x0, width * height * sizeof(UINT));	
	memset(mask, 0x0, width * height * sizeof(UINT));	

	Icon icon = icons[index];

	//Paint the icon onto the DC		
	result = DrawIconEx(iconContext, 0, 0, icon.getIcon(), icon.getWidth(), icon.getHeight(), 0, NULL, DI_NORMAL); 	
	checkResult(result, "Failed to draw icon into memory");

	//Paint the icon onto the DC		
	result = DrawIconEx(maskContext, 0, 0, icon.getIcon(), icon.getWidth(), icon.getHeight(), 0, NULL, DI_MASK); 
	checkResult(result, "Failed to draw icon alpha mask into memory");

	//pixels and mask now contain the data
	int *dimensions = new int[2];
	dimensions[0] = icon.getWidth();
	dimensions[1] = icon.getHeight();

	return dimensions;
}
コード例 #2
0
//Free all of our buffers, release the DIB and DC
void IconSet::destroy()
{
	SelectObject(iconContext, oldObjIcon);	
	SelectObject(maskContext, oldObjMask);

	DeleteObject(iconBitmap);
	DeleteObject(maskBitmap);

	DeleteDC(iconContext);	
	DeleteDC(maskContext);

	//Delete the icon resources
	vector<Icon>::const_iterator start = icons.begin();
	vector<Icon>::const_iterator end = icons.end();

		width = height = 0;

	while (start != end)
	{
		Icon icon = *start;
		DestroyIcon( icon.getIcon() );

		start++;
	}

	pixels = NULL;
	mask = NULL;
}