--- q_a/samples/streblt/bitmap.c 2018/08/09 18:29:19 1.1.1.1 +++ q_a/samples/streblt/bitmap.c 2018/08/09 18:29:46 1.1.1.2 @@ -1,9 +1,18 @@ + +/******************************************************************************\ +* This is a part of the Microsoft Source Code Samples. +* Copyright (C) 1993 Microsoft Corporation. +* All rights reserved. +* This source code is only intended as a supplement to +* Microsoft Development Tools and/or WinHelp documentation. +* See these sources for detailed information regarding the +* Microsoft samples programs. +\******************************************************************************/ + /**************************************************************************\ * bitmap.c -- support for reading in and drawing bitmaps. -* \**************************************************************************/ -#define STRICT #include #include @@ -73,19 +82,19 @@ HBITMAP GetBitmap (HDC hdc, HANDLE hInst of.hInstance = hInst; of.lpstrFilter = "Bitmaps\000 *.BMP\000\000"; of.lpstrCustomFilter = NULL; - of.nMaxCustFilter = NULL; - of.nFilterIndex = NULL; + of.nMaxCustFilter = 0; + of.nFilterIndex = 0; of.lpstrFile = buffer; of.nMaxFile = MAX_PATH; of.lpstrFileTitle = NULL; - of.nMaxFileTitle = NULL; + of.nMaxFileTitle = 0; of.lpstrInitialDir = "c:\\nt\\windows"; of.lpstrTitle = NULL; - of.Flags = OFN_READONLY; - of.nFileOffset = NULL; - of.nFileExtension = NULL; + of.Flags = OFN_HIDEREADONLY; + of.nFileOffset = 0; + of.nFileExtension = 0; of.lpstrDefExt = NULL; - of.lCustData = NULL; + of.lCustData = 0; of.lpfnHook = NULL; of.lpTemplateName = NULL; if (!GetOpenFileName (&of)) return NULL; @@ -125,18 +134,25 @@ HBITMAP GetBitmap (HDC hdc, HANDLE hInst /* in the case of desiring a monochrome bitmap (input parameter), - * verify that is what we got. + * verify that is what we got. If it is, then use CreateBitmap, + * else use a device independent bitmap. */ - if (monochrome && ( pbmih->biBitCount != 1)) { + if (monochrome) { + if (pbmih->biBitCount != 1) { MessageBox (NULL, "Mask must be monochrome bitmap.", "Error", MB_APPLMODAL | MB_ICONSTOP | MB_OK); hbm = NULL; - } else - - - hbm = CreateDIBitmap (hdc, pbmih, CBM_INIT, + } else { + hbm = CreateBitmap (pbmih->biWidth, pbmih->biHeight, + pbmih->biPlanes, pbmih->biBitCount, + pBits); + } + } else /* bitmap is NOT monochrome, use DIB. */ + hbm = CreateDIBitmap (hdc, pbmih, CBM_INIT, pBits, (PBITMAPINFO) pbmih, DIB_RGB_COLORS); + + /* hbm is set... free up memory, and return */ LocalFree (LocalHandle ((LPSTR)pBits)); LocalFree (LocalHandle ((LPSTR)pbmih)); LocalFree (LocalHandle ((LPSTR)pbmfh));