_LoadBMP proc _hWnd,_lpFileName
local @hFile,@hFileMap,@lpMemory,@lpBitmapBits,@lpBitmapInfo
local @dwWidth,@dwHeight,@hTempDC,@hBitmap
invoke _UnLoadBMP
push _hWnd
pop MYBMP_hWnd
invoke CreateFile,_lpFileName,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
.if eax == INVALID_HANDLE_VALUE
jmp Err
.endif
mov @hFile,eax
invoke CreateFileMapping,@hFile,NULL,PAGE_READONLY,0,0,NULL
.if !eax
invoke CloseHandle,@hFile
jmp Err
.endif
mov @hFileMap,eax
invoke MapVIEwOfFile,@hFileMap,FILE_MAP_READ,0,0,0
.if !eax
invoke CloseHandle,@hFileMap
invoke CloseHandle,@hFile
jmp Err
.endif
mov @lpMemory,eax
mov esi,eax
.if BITMAPFILEHEADER.bfType[esi] != 'BM'
invoke UnmapVIEwOfFile,@lpMemory
invoke CloseHandle,@hFileMap
invoke CloseHandle,@hFile
jmp Err
.endif
mov eax,BITMAPFILEHEADER.bfOffBits[esi]
add eax,esi
mov @lpBitmapBits,esi
add esi,sizeof BITMAPFILEHEADER
mov @lpBitmapInfo,esi
.if BITMAPINFO.bmiHeader.biSize[esi] == sizeof BITMAPCOREHEADER
movzx eax,BITMAPCOREHEADER.bcWidth[esi]
movzx ebx,
BITMAPCOREHEADER.bcHeight[esi]
.elseif
mov eax,BITMAPINFOHEADER.biWidth[esi]
mov eax,BITMAPINFOHEADER.biHeight[esi]
.endif
mov MYBMP_dwWidth,eax
mov MYBMP_dwHeight,ebx
invoke GetDC,_hWnd
mov @hTempDC,eax
invoke CreateCompatibleDC,eax
mov MYBMP_hDC,eax
invoke CreateCompatibleBitmap,@hTempDC,MYBMP_dwWidth,MYBMP_dwHeight
mov @hBitmap,eax
invoke SelectObject,MYBMP_hDC,@hBitmap
invoke SetDIBitsToDevice,MYBMP_hDC,0,0,MYBMP_dwWidth,MYBMP_dwHeight,0,0,0,MYBMP_dwHeight,@lpBitmapBits,@lpBitmapInfo,DIB_RGB_COLORS
invoke ReleaseDC,_hWnd,@hTempDC
invoke DeleteObject,@hBitmap
invoke UnmapVIEwOfFile,@lpMemory
invoke CloseHandle,@hFileMap
invoke CloseHandle,@hFile
mov eax,TRUE
ret
Err:
mov eax,FALSE
ret
_LoadBMP endp
_ShowBMP proc
local @hTempDC
invoke GetDC,MYBMP_hWnd
mov @hTempDC,eax
invoke BitBlt,@hTempDC,0,0,MYBMP_dwWidth,MYBMP_dwHeight,MYBMP_hDC,0,0,SRCCOPY
invoke ReleaseDC,MYBMP_hWnd,@hTempDC
ret
_ShowMBP endp