Exemplo n.º 1
0
/* Allow us to pre-load the DIB once for future draws */
#ifdef MESS
BOOL LoadScreenShotEx(int nGame, LPCSTR lpSoftwareName, int nType)
#else /* !MESS */
BOOL LoadScreenShot(int nGame, int nType)
#endif /* MESS */
{
	BOOL loaded = FALSE;
	/* No need to reload the same one again */
#ifndef MESS
	if (nGame == current_image_game && nType == current_image_type)
		return TRUE;
#endif

	/* Delete the last ones */
	FreeScreenShot();

	/* Load the DIB */
#ifdef MESS
	if (lpSoftwareName)
	{
		int nParentIndex = -1;
		loaded = LoadSoftwareScreenShot(drivers[nGame], lpSoftwareName, nType);
		if (!loaded && DriverIsClone(nGame) == TRUE)
		{
			nParentIndex = GetParentIndex(drivers[nGame]);
			loaded = LoadSoftwareScreenShot(drivers[nParentIndex], lpSoftwareName, nType);
		}
	}
	if (!loaded)
#endif /* MESS */
	{
		loaded = LoadDIB(drivers[nGame]->name, &m_hDIB, &m_hPal, nType);
	}

	/* If not loaded, see if there is a clone and try that */
	if (!loaded)
	{
		int nParentIndex = GetParentIndex(drivers[nGame]);
		if( nParentIndex >= 0)
		{
			loaded = LoadDIB(drivers[nParentIndex]->name, &m_hDIB, &m_hPal, nType);
			nParentIndex = GetParentIndex(drivers[nParentIndex]);
			if (!loaded && nParentIndex >= 0)
				loaded = LoadDIB(drivers[nParentIndex]->name, &m_hDIB, &m_hPal, nType);
		}
	}

	if (loaded)
	{
		HDC hdc = GetDC(GetMainWindow());
		m_hDDB = DIBToDDB(hdc, m_hDIB, NULL);
		ReleaseDC(GetMainWindow(),hdc);
		
		current_image_game = nGame;
		current_image_type = nType;

	}

	return (loaded) ? TRUE : FALSE;
}
Exemplo n.º 2
0
/* Allow us to pre-load the DIB once for future draws */
#ifdef MESS
BOOL LoadScreenShotEx(int nGame, LPCSTR lpSoftwareName, int nType)
#else /* !MESS */
BOOL LoadScreenShot(int nGame, int nType)
#endif /* MESS */
{
	BOOL loaded = FALSE;

	/* No need to reload the same one again */
#ifndef MESS
	if (nGame == current_image_game && nType == current_image_type)
		return TRUE;
#endif

	/* Delete the last ones */
	FreeScreenShot();

	/* Load the DIB */
#ifdef MESS
	if (lpSoftwareName)
	{
		loaded = LoadSoftwareScreenShot(drivers[nGame], lpSoftwareName, nType);
		if (!loaded && (drivers[nGame]->clone_of && !(drivers[nGame]->clone_of->flags & NOT_A_DRIVER)))
			loaded = LoadSoftwareScreenShot(drivers[nGame]->clone_of, lpSoftwareName, nType);
	}
	if (!loaded)
#endif /* MESS */
	{
		loaded = LoadDIB(drivers[nGame]->name, &m_hDIB, &m_hPal, nType);
	}

	/* If not loaded, see if there is a clone and try that */
	if (!loaded
	&&	 (drivers[nGame]->clone_of != NULL)
	&&	!(drivers[nGame]->clone_of->flags & NOT_A_DRIVER))
	{
		loaded = LoadDIB(drivers[nGame]->clone_of->name, &m_hDIB, &m_hPal, nType);
		if (!loaded && drivers[nGame]->clone_of->clone_of)
			loaded = LoadDIB(drivers[nGame]->clone_of->clone_of->name, &m_hDIB, &m_hPal, nType);
	}

	if (loaded)
	{
		HDC hdc = GetDC(GetMainWindow());
		m_hDDB = DIBToDDB(hdc, m_hDIB, NULL);
		ReleaseDC(GetMainWindow(),hdc);
		
		current_image_game = nGame;
		current_image_type = nType;

	}

	return (loaded) ? TRUE : FALSE;
}
Exemplo n.º 3
0
HBITMAP PaletteLoadBitmap(HINSTANCE hInst, LPCTSTR pBitmapName, HPALETTE hPalette)
{
	bool bDIBNeedFree;
	BITMAPINFO * pDIB = LoadDIB(hInst, pBitmapName, bDIBNeedFree);

	int width     = pDIB->bmiHeader.biWidth;
	int height    = pDIB->bmiHeader.biHeight;

	HDC hMemDC    = CreateCompatibleDC(NULL);
	HBITMAP hBmp  = CreateBitmap(width, height, GetDeviceCaps(hMemDC, PLANES), GetDeviceCaps(hMemDC, BITSPIXEL), NULL);
	
	HGDIOBJ hOldBmp = SelectObject(hMemDC, hBmp);

	HPALETTE hOld = SelectPalette(hMemDC, hPalette, FALSE);
	RealizePalette(hMemDC);

	SetStretchBltMode(hMemDC, HALFTONE);
	StretchDIBits(hMemDC, 0, 0, width, height, 0, 0, width, height, GetDIBPixelArray(pDIB), pDIB, DIB_RGB_COLORS, SRCCOPY);

	SelectPalette(hMemDC, hOld, FALSE);
	SelectObject(hMemDC, hOldBmp);
	DeleteObject(hMemDC);
	
	if ( bDIBNeedFree )
		delete [] (BYTE *) pDIB;

	return hBmp;
}
Exemplo n.º 4
0
static BOOL LoadSoftwareScreenShot(const game_driver *drv, LPCSTR lpSoftwareName, int nType)
{
	BOOL result;
	char *s = (char*)alloca(strlen(drv->name) + 1 + strlen(lpSoftwareName) + 5);
	sprintf(s, "%s/%s.png", drv->name, lpSoftwareName);
	result = LoadDIB(s, &m_hDIB, &m_hPal, nType);
	return result;
}
Exemplo n.º 5
0
/* Allow us to pre-load the DIB once for future draws */
BOOL LoadScreenShotEx(int nGame, LPCSTR lpSoftwareName, int nType)
{
	BOOL loaded = FALSE;

	/* Delete the last ones */
	FreeScreenShot();

	/* Load the DIB */

	if (lpSoftwareName)
	{
		int nParentIndex = -1;
		loaded = LoadSoftwareScreenShot(&driver_list::driver(nGame), lpSoftwareName, nType);
		if (!loaded && DriverIsClone(nGame) == TRUE)
		{
			nParentIndex = GetParentIndex(&driver_list::driver(nGame));
			loaded = LoadSoftwareScreenShot(&driver_list::driver(nParentIndex), lpSoftwareName, nType);
		}
	}

	if (!loaded)
		loaded = LoadDIB(driver_list::driver(nGame).name, &m_hDIB, &m_hPal, nType);

	/* If not loaded, see if there is a clone and try that */
	if (!loaded)
	{
		int nParentIndex = GetParentIndex(&driver_list::driver(nGame));
		if( nParentIndex >= 0)
		{
			loaded = LoadDIB(driver_list::driver(nParentIndex).name, &m_hDIB, &m_hPal, nType);
			nParentIndex = GetParentIndex(&driver_list::driver(nParentIndex));
			if (!loaded && nParentIndex >= 0)
				loaded = LoadDIB(driver_list::driver(nParentIndex).name, &m_hDIB, &m_hPal, nType);
		}
	}

	if (loaded)
	{
		HDC hdc = GetDC(GetMainWindow());
		m_hDDB = DIBToDDB(hdc, m_hDIB, NULL);
		ReleaseDC(GetMainWindow(),hdc);
	}

	return (loaded) ? TRUE : FALSE;
}
Exemplo n.º 6
0
/* Allow us to pre-load the DIB once for future draws */
#ifdef MESS
BOOL LoadScreenShotEx(int nGame, LPCSTR lpSoftwareName, int nType)
#else /* !MESS */
BOOL LoadScreenShot(int nGame, int nType)
#endif /* MESS */
{
	BOOL loaded = FALSE;
	/* No need to reload the same one again */
#ifndef MESS
	if (nGame == current_image_game && nType == current_image_type)
		return TRUE;
#endif

	/* Delete the last ones */
	FreeScreenShot();

	/* Load the DIB */
#ifdef MESS
	if (lpSoftwareName)
	{
		int nParentIndex = -1;
		loaded = LoadSoftwareScreenShot(&driver_list::driver(nGame), lpSoftwareName, nType);
		if (!loaded && DriverIsClone(nGame) == TRUE)
		{
			nParentIndex = GetParentIndex(&driver_list::driver(nGame));
			loaded = LoadSoftwareScreenShot(&driver_list::driver(nParentIndex), lpSoftwareName, nType);
		}
	}
	if (!loaded)
#endif /* MESS */
	{
		loaded = LoadDIB(driver_list::driver(nGame).name, &m_hDIB, &m_hPal, nType);
	}

	/* If not loaded, see if there is a clone and try that */
	if (!loaded)
	{
		int nParentIndex = GetParentIndex(&driver_list::driver(nGame));
		if( nParentIndex >= 0)
		{
			loaded = LoadDIB(driver_list::driver(nParentIndex).name, &m_hDIB, &m_hPal, nType);
			nParentIndex = GetParentIndex(&driver_list::driver(nParentIndex));
			if (!loaded && nParentIndex >= 0)
				loaded = LoadDIB(driver_list::driver(nParentIndex).name, &m_hDIB, &m_hPal, nType);
		}
	}

#ifndef MESS
	/* MSH 20071029 - If driver is broken and no images exists, look for nonworking.png */
	if (!loaded && DriverIsBroken(nGame))
	{
		loaded = LoadDIB("nonworking", &m_hDIB, &m_hPal, nType);
	}
#endif

	if (loaded)
	{
		HDC hdc = GetDC(GetMainWindow());
		m_hDDB = DIBToDDB(hdc, m_hDIB, NULL);
		ReleaseDC(GetMainWindow(),hdc);

		current_image_game = nGame;
		current_image_type = nType;

	}

	return (loaded) ? TRUE : FALSE;
}
Exemplo n.º 7
0
static BOOL LoadSoftwareScreenShot(const struct GameDriver *drv, LPCSTR lpSoftwareName, int nType)
{
	char *s = alloca(strlen(drv->name) + 1 + strlen(lpSoftwareName) + 5);
	sprintf(s, "%s/%s.png", drv->name, lpSoftwareName);
	return LoadDIB(s, &m_hDIB, &m_hPal, nType);
}
Exemplo n.º 8
0
/* Allow us to pre-load the DIB once for future draws */
#ifdef MESS
BOOL LoadScreenShotEx(int nGame, LPCSTR lpSoftwareName, int nType)
#else /* !MESS */
#ifdef USE_IPS
BOOL LoadScreenShot(int nGame, LPCWSTR lpIPSName, int nType)
#else /* USE_IPS */
BOOL LoadScreenShot(int nGame, int nType)
#endif /* USE_IPS */
#endif /* MESS */
{
	BOOL loaded = FALSE;
	int nIndex = nGame;

	/* No need to reload the same one again */
#ifndef MESS
	if (nGame == current_image_game && nType == current_image_type)
		return TRUE;
#endif

	/* Delete the last ones */
	FreeScreenShot();

	/* Load the DIB */
#ifdef MESS
	if (lpSoftwareName)
	{
		int nParentIndex = -1;
		loaded = LoadSoftwareScreenShot(&driver_list::driver(nGame), lpSoftwareName, nType);
		if (!loaded && DriverIsClone(nGame) == TRUE)
		{
			nParentIndex = GetParentIndex(drivers[nGame]);
			loaded = LoadSoftwareScreenShot(&driver_list::driver(nParentIndex), lpSoftwareName, nType);
		}
	}
	if (!loaded)
#endif /* MESS */
	{
#ifdef USE_IPS
		if (lpIPSName)
		{
			WCHAR *wdrv = driversw[nIndex]->name;
			WCHAR buf[MAX_PATH];

			wsprintf(buf, TEXT("%s/%s"), wdrv, lpIPSName);
			dwprintf(TEXT("found ipsname: %s"), buf);

			while (!loaded && nIndex >= 0)
			{
				wdrv = driversw[nIndex]->name;
				wsprintf(buf, TEXT("%s/%s"), wdrv, lpIPSName);
				loaded = LoadDIB(buf, &m_hDIB, &m_hPal, nType);
				nIndex = GetParentIndex(&driver_list::driver(nIndex));
			}
		}
		else
#endif /* USE_IPS */
		{
			dwprintf(TEXT("not found ipsname: %s"), driversw[nIndex]->name);

			while (!loaded && nIndex >= 0)
			{
				loaded = LoadDIB(driversw[nIndex]->name, &m_hDIB, &m_hPal, nType);
				nIndex = GetParentIndex(&driver_list::driver(nIndex));
			}
		}
	}

	if (loaded)
	{
		HDC hdc = GetDC(GetMainWindow());
		m_hDDB = DIBToDDB(hdc, m_hDIB, NULL);
		ReleaseDC(GetMainWindow(),hdc);

		current_image_game = nGame;
		current_image_type = nType;

	}

	return (loaded) ? TRUE : FALSE;
}
Exemplo n.º 9
0
WinHelpPicture::WinHelpPicture(QIODevice &device, qint64 off) : pictures()
{
    PRINT_DBG("Reading WinHelp picture at: %lld", off);
    seekFile(device, off);
    PictureHeader pictHdr(device, off);
    for(int i = 0; i < pictHdr.getNumberOfPictures(); i++)
    {
        qint64 pictOffset = off +
            static_cast<qint64>(pictHdr.getPictureOffset(i));
        PictureInfoHeader pictInfoHdr(device, pictOffset);
        switch(pictInfoHdr.getPictureType())
        {
        case DDB_PICTURE:
        {
            BitmapHeader bitmapHdr(device, pictOffset + PictureInfoHeader::size);
            seekFile(device, pictOffset + bitmapHdr.getCompressedOffset());
            switch(pictInfoHdr.getPackingMethod())
            {
            case UNCOMPRESSED_PICTURE:
            {
                this->pictures.append(LoadDDB(device, pictOffset +
                                static_cast<qint64>(bitmapHdr.
                                    getCompressedOffset()),
                                static_cast<size_t>(bitmapHdr.getCompressedSize()),
                                bitmapHdr));
            }
            break;

            case RUNLEN_COMPRESSED_PICTURE:
            {
                QBuffer uncompressedBuffer;
                uncompressedBuffer.open(QIODevice::ReadWrite);
                size_t sz = unpackRLEUnknownOutputSize(device,
                            pictOffset +
                            static_cast<qint64>(bitmapHdr.getCompressedOffset()),
                            static_cast<size_t>(bitmapHdr.getCompressedSize()),
                            uncompressedBuffer);
                this->pictures.append(LoadDDB(uncompressedBuffer, Q_INT64_C(0),
                                sz, bitmapHdr));
                uncompressedBuffer.close();
            }
            break;

            case LZ77_COMPRESSED_PICTURE:
            {
                QBuffer uncompressedBuffer;
                uncompressedBuffer.open(QIODevice::ReadWrite);
                size_t sz = unpackLZ77UnknownOutputSize(device,
                            pictOffset +
                            static_cast<qint64>(bitmapHdr.getCompressedOffset()),
                            static_cast<size_t>(bitmapHdr.getCompressedSize()),
                            uncompressedBuffer);
                this->pictures.append(LoadDDB(uncompressedBuffer, Q_INT64_C(0),
                                sz, bitmapHdr));
                uncompressedBuffer.close();
            }
            break;

            case LZ77_AND_RUNLEN_COMPRESSED_PICTURE:
            {
                QBuffer unpackedBuffer;
                unpackedBuffer.open(QIODevice::ReadWrite);
                size_t szUnpacked = unpackLZ77UnknownOutputSize(device,
                            pictOffset +
                            static_cast<qint64>(bitmapHdr.getCompressedOffset()),
                            static_cast<size_t>(bitmapHdr.getCompressedSize()),
                            unpackedBuffer);
                QBuffer uncompressedBuffer;
                uncompressedBuffer.open(QIODevice::ReadWrite);
                size_t sz = unpackRLEUnknownOutputSize(unpackedBuffer,
                            Q_INT64_C(0),
                            szUnpacked,
                            uncompressedBuffer);
                this->pictures.append(LoadDDB(uncompressedBuffer, Q_INT64_C(0),
                                sz, bitmapHdr));
                uncompressedBuffer.close();
            }
            break;

            default:
                throw std::runtime_error("Unknown image compression method");
            }
        }
        break;

        case DIB_PICTURE:
        {
            BitmapHeader bitmapHdr(device, pictOffset + PictureInfoHeader::size);
            int paletteSize = bitmapHdr.getColorsUsed();
            QScopedArrayPointer<QRgb> palette;
            if(paletteSize != 0)
            {
                if(paletteSize > 256)
                {
                    throw std::runtime_error("Palette is too big");
                }
                QScopedArrayPointer<QRgb>(new QRgb[paletteSize]).swap(palette);
                for(int i = 0; i < paletteSize; i++)
                {
                    palette[i] = readBGRDword(device);
                }
            }
            seekFile(device, pictOffset + bitmapHdr.getCompressedOffset());
            switch(pictInfoHdr.getPackingMethod())
            {
            case UNCOMPRESSED_PICTURE:
            {
                this->pictures.append(LoadDIB(device, pictOffset +
                                static_cast<qint64>(bitmapHdr.
                                    getCompressedOffset()),
                                static_cast<size_t>(bitmapHdr.getCompressedSize()),
                                bitmapHdr, palette));
            }
            break;

            case RUNLEN_COMPRESSED_PICTURE:
            {
                QBuffer uncompressedBuffer;
                uncompressedBuffer.open(QIODevice::ReadWrite);
                size_t sz = unpackRLEUnknownOutputSize(device,
                            pictOffset +
                            static_cast<qint64>(bitmapHdr.getCompressedOffset()),
                            static_cast<size_t>(bitmapHdr.getCompressedSize()),
                            uncompressedBuffer);
                this->pictures.append(LoadDIB(uncompressedBuffer, Q_INT64_C(0),
                                sz, bitmapHdr, palette));
                uncompressedBuffer.close();
            }
            break;

            case LZ77_COMPRESSED_PICTURE:
            {
                QBuffer uncompressedBuffer;
                uncompressedBuffer.open(QIODevice::ReadWrite);
                size_t sz = unpackLZ77UnknownOutputSize(device,
                            pictOffset +
                            static_cast<qint64>(bitmapHdr.getCompressedOffset()),
                            static_cast<size_t>(bitmapHdr.getCompressedSize()),
                            uncompressedBuffer);
                this->pictures.append(LoadDIB(uncompressedBuffer, Q_INT64_C(0),
                                sz, bitmapHdr, palette));
                uncompressedBuffer.close();
            }
            break;

            case LZ77_AND_RUNLEN_COMPRESSED_PICTURE:
            {
                QBuffer unpackedBuffer;
                unpackedBuffer.open(QIODevice::ReadWrite);
                size_t szUnpacked = unpackLZ77UnknownOutputSize(device,
                            pictOffset +
                            static_cast<qint64>(bitmapHdr.getCompressedOffset()),
                            static_cast<size_t>(bitmapHdr.getCompressedSize()),
                            unpackedBuffer);
                QBuffer uncompressedBuffer;
                uncompressedBuffer.open(QIODevice::ReadWrite);
                size_t sz = unpackRLEUnknownOutputSize(unpackedBuffer,
                            Q_INT64_C(0),
                            szUnpacked,
                            uncompressedBuffer);
                this->pictures.append(LoadDIB(uncompressedBuffer, Q_INT64_C(0),
                                sz, bitmapHdr, palette));
                uncompressedBuffer.close();
            }
            break;

            default:
                throw std::runtime_error("Unknown image compression method");
            }
        }
        break;

        case METAFILE_PICTURE:
        {
            MetafileHeader metafileHdr(device,
                    pictOffset + PictureInfoHeader::size);
            qDebug() << "Metafiles are not supported";
            if(((metafileHdr.getWidth()/20) * (metafileHdr.getHeight()/20)) <= 1920000)
            {
                QImage unsupportedImage(
                        metafileHdr.getWidth()/20,
                        metafileHdr.getHeight()/20, QImage::Format_ARGB32);
                QPainter painter;
                painter.begin(&unsupportedImage);
                painter.fillRect(0, 0,
                        metafileHdr.getWidth(),
                        metafileHdr.getHeight(), Qt::white);
                painter.drawText(20, 20, "Unsupported");
                painter.end();
                this->pictures.append(unsupportedImage);
            }
            else
            {
                qDebug() << "Metafile is too large";
                QImage unsupportedImage(100, 100, QImage::Format_ARGB32);
                QPainter painter;
                painter.begin(&unsupportedImage);
                painter.fillRect(0, 0,
                        metafileHdr.getWidth(),
                        metafileHdr.getHeight(), Qt::white);
                painter.drawText(20, 20, "Unsupported");
                painter.end();
                this->pictures.append(unsupportedImage);
            }
        }
        break;

        default:
            throw std::runtime_error( "Unknown picture type");
        }
    }
    PRINT_DBG("WinHelp picture loaded successfully");
}