Bitmap.c: Cleanup some memory management
git-svn-id: svn://vcs.sdm.2ki.xyz/Grabby/trunk@12 27729192-006e-004d-b9b5-06fbd0ef7001
This commit is contained in:
parent
d64803c1a9
commit
7d1c91401f
10
Bitmap.c
10
Bitmap.c
|
@ -36,6 +36,9 @@ void
|
||||||
DeleteScreen(Screen *scrn)
|
DeleteScreen(Screen *scrn)
|
||||||
{
|
{
|
||||||
if (scrn) {
|
if (scrn) {
|
||||||
|
if (scrn->hOldObj) SelectObject(scrn->hdcBitmap, scrn->hOldObj);
|
||||||
|
if (scrn->hBitmap) DeleteObject(scrn->hBitmap);
|
||||||
|
|
||||||
if (scrn->hScreenRgn) DeleteObject((HGDIOBJ) scrn->hScreenRgn);
|
if (scrn->hScreenRgn) DeleteObject((HGDIOBJ) scrn->hScreenRgn);
|
||||||
if (scrn->hdcBitmap) DeleteDC(scrn->hdcBitmap);
|
if (scrn->hdcBitmap) DeleteDC(scrn->hdcBitmap);
|
||||||
if (scrn->hdcScreen) DeleteDC(scrn->hdcScreen);
|
if (scrn->hdcScreen) DeleteDC(scrn->hdcScreen);
|
||||||
|
@ -57,9 +60,12 @@ PFULLBMPHDR
|
||||||
GenerateBitmapInfo(Screen *scrn,
|
GenerateBitmapInfo(Screen *scrn,
|
||||||
BITMAP *bmp)
|
BITMAP *bmp)
|
||||||
{
|
{
|
||||||
|
// GDI seems to modify the DWORD after the info header, even if we
|
||||||
|
// don't need a palette (>8 bit BMPs). Thus, an extra RGBQUAD just
|
||||||
|
// to be safe.
|
||||||
PFULLBMPHDR pBmpHdr = HeapAlloc(GetProcessHeap(),
|
PFULLBMPHDR pBmpHdr = HeapAlloc(GetProcessHeap(),
|
||||||
HEAP_ZERO_MEMORY,
|
HEAP_ZERO_MEMORY,
|
||||||
sizeof(struct _FULLBMPHDR));
|
sizeof(struct _FULLBMPHDR) + sizeof(RGBQUAD));
|
||||||
RECT rcScrn = {0};
|
RECT rcScrn = {0};
|
||||||
WORD cClrBits = (WORD)(bmp->bmPlanes * bmp->bmBitsPixel);
|
WORD cClrBits = (WORD)(bmp->bmPlanes * bmp->bmBitsPixel);
|
||||||
DWORD hdrSize;
|
DWORD hdrSize;
|
||||||
|
@ -337,10 +343,8 @@ cleanup:
|
||||||
|
|
||||||
if (pHdr) HeapFree(GetProcessHeap(), 0, pHdr);
|
if (pHdr) HeapFree(GetProcessHeap(), 0, pHdr);
|
||||||
|
|
||||||
if (scrn->hOldObj) SelectObject(scrn->hdcBitmap, scrn->hOldObj);
|
|
||||||
if (hOldObj) SelectObject(hdcRgn, hOldObj);
|
if (hOldObj) SelectObject(hdcRgn, hOldObj);
|
||||||
if (hRgnBitmap) DeleteObject(hRgnBitmap);
|
if (hRgnBitmap) DeleteObject(hRgnBitmap);
|
||||||
if (scrn->hBitmap) DeleteObject(scrn->hBitmap);
|
|
||||||
|
|
||||||
if (hdcRgn) DeleteDC(hdcRgn);
|
if (hdcRgn) DeleteDC(hdcRgn);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue