Make piece bitmaps larger and crisper
cosinekitty opened this issue · comments
Don Cross commented
The 1990s graphics are really starting to show their age. I will replace them with larger and crisper bitmaps. I don't think I need multiple piece styles any more, just the one that most people seem to use in modern chess programs.
Bonus points if I can:
- rework move animation to show pieces sliding rather than blinking (requires transparent areas on the bitmaps).
- allow the user to drag pieces instead of just clicking on source and destination squares (ditto for transparency).
- resize the board dynamically to any size by dragging the corner of the window.
Don Cross commented
I found the following from
I'm hoping it gives me a clue for how to load from a PNG with a transparent background into an old-style Windows program.
bool GdiPlusUtils::LoadBitmapFromPNG(UINT uResourceID,
Bitmap** ppBitmapOut, HINSTANCE hInstance /*= NULL*/)
{
bool bRet = false;
if (!hInstance)
hInstance = AfxGetInstanceHandle();
HRSRC hResourceHandle = ::FindResource(
hInstance, MAKEINTRESOURCE(uResourceID), L"PNG");
if (0 == hResourceHandle)
{
return bRet;
}
DWORD nImageSize = ::SizeofResource(hInstance, hResourceHandle);
if (0 == nImageSize)
{
return bRet;
}
HGLOBAL hResourceInstance = ::LoadResource(hInstance, hResourceHandle);
if (0 == hResourceInstance)
{
return bRet;
}
const void* pResourceData = ::LockResource(hResourceInstance);
if (0 == pResourceData)
{
FreeResource(hResourceInstance);
return bRet;
}
HGLOBAL hBuffer = ::GlobalAlloc(GMEM_MOVEABLE, nImageSize);
if (0 == hBuffer)
{
FreeResource(hResourceInstance);
return bRet;
}
void* pBuffer = ::GlobalLock(hBuffer);
if (0 != pBuffer)
{
CopyMemory(pBuffer, pResourceData, nImageSize);
IStream* pStream = 0;
if (S_OK == ::CreateStreamOnHGlobal(hBuffer, FALSE, &pStream))
{
*ppBitmapOut = new Bitmap(pStream);
pStream->Release();
bRet = true;
}
::GlobalUnlock(hBuffer);
}
::GlobalFree(hBuffer);
UnlockResource(hResourceInstance);
FreeResource(hResourceInstance);
return bRet;
}