コード例 #1
0
bool Win32ResExtractor::extractResource(int id, CachedCursor *cc) {
	if (_fileName.empty()) { // We are running for the first time
		_fileName = _vm->generateFilename(-3);

		if (!_exe.loadFromEXE(_fileName))
			error("Cannot open file %s", _fileName.c_str());
	}

	Graphics::WinCursorGroup *group = Graphics::WinCursorGroup::createCursorGroup(_exe, id);

	if (!group)
		return false;

	Graphics::WinCursor *cursor = group->cursors[0].cursor;

	cc->bitmap = new byte[cursor->getWidth() * cursor->getHeight()];
	cc->width = cursor->getWidth();
	cc->height = cursor->getHeight();
	cc->hotspotX = cursor->getHotspotX();
	cc->hotspotY = cursor->getHotspotY();

	// Convert from the paletted format to the SCUMM palette
	const byte *srcBitmap = cursor->getSurface();

	for (int i = 0; i < cursor->getWidth() * cursor->getHeight(); i++) {
		if (srcBitmap[i] == cursor->getKeyColor()) // Transparent
			cc->bitmap[i] = 255;
		else if (srcBitmap[i] == 0)                // Black
			cc->bitmap[i] = 253;
		else                                       // White
			cc->bitmap[i] = 254;
	}

	delete group;
	return true;
}
コード例 #2
0
ファイル: cursors.cpp プロジェクト: zekizeki2010/scummvm
void PECursorManager::setCursor(uint16 id) {
	if (_exe) {
		Graphics::WinCursorGroup *cursorGroup = Graphics::WinCursorGroup::createCursorGroup(*_exe, id);

		if (cursorGroup) {
			Graphics::WinCursor *cursor = cursorGroup->cursors[0].cursor;
			CursorMan.replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(), cursor->getHotspotY(), cursor->getKeyColor());
			CursorMan.replaceCursorPalette(cursor->getPalette(), 0, 256);
			delete cursorGroup;
			return;
		}
	}

	// Last resort (not all have cursors)
	setDefaultCursor();
}