[MSPAINT] Add CachedBufferDIB function and use it

We do caching on buffering paint.
This will improve performance a little.
CORE-18867
This commit is contained in:
Katayama Hirofumi MZ 2023-06-16 08:05:23 +09:00
parent c706222f3f
commit 2f856f6f0d
8 changed files with 73 additions and 9 deletions

View file

@ -59,6 +59,26 @@ CreateColorDIB(int width, int height, COLORREF rgb)
return ret;
}
HBITMAP CachedBufferDIB(HBITMAP hbm, int minimalWidth, int minimalHeight)
{
if (minimalWidth <= 0)
minimalWidth = 1;
if (minimalHeight <= 0)
minimalHeight = 1;
BITMAP bm;
if (!GetObject(hbm, sizeof(bm), &bm))
hbm = NULL;
if (hbm && minimalWidth <= bm.bmWidth && minimalHeight <= bm.bmHeight)
return hbm;
if (hbm)
DeleteObject(hbm);
return CreateDIBWithProperties((minimalWidth * 3) / 2, (minimalHeight * 3) / 2);
}
int
GetDIBWidth(HBITMAP hBitmap)
{