00001 //------------------------------------------------------------------------------ 00002 // DIBVIEW.CPP -- 00003 // 00004 //------------------------------------------------------------------------------ 00005 #define STRICT 00006 #include <windows.h> 00007 #include <windowsx.h> 00008 #pragma hdrstop 00009 #include <mem.h> 00010 00011 #include "dibclass.h" 00012 #include "dibview.h" 00013 #include "dibapi.h" 00014 00015 00016 //------------------------------------------------------------------------------ 00017 // The DIBVIEW class 00018 //------------------------------------------------------------------------------ 00019 DIBVIEW::DIBVIEW() 00020 { 00021 // memset(this, 0, sizeof(DIBVIEW)); 00022 wDisplay = DIB_ACTUAL; 00023 } 00024 00025 void DIBVIEW::PaintDIB(HWND hwnd, HDC hdc) 00026 { 00027 LPBITMAPINFO lpBmpInfo = GetDib(); 00028 HPALETTE hOldPal; 00029 HANDLE hDIB = GlobalPtrHandle(lpBmpInfo); 00030 LPSTR lpDIBHdr, lpDIBBits; 00031 00032 hOldPal = RealizeDIBPalette(hdc, hDIB); 00033 00034 if(lpBmpInfo) 00035 { 00036 switch(GetDisplayType()) 00037 { 00038 case DIB_ACTUAL: 00039 PaintDIBInBands(hdc, hDIB, cxDib, cyDib, cyDib); 00040 break; 00041 00042 case DIB_STRETCH: 00043 break; 00044 00045 case DIB_TILE: 00046 { 00047 RECT r; 00048 int nx, ny, yOffset; 00049 00050 GetClientRect(hwnd, &r); 00051 nx = (r.right - r.left) / cxDib; 00052 ny = (r.bottom - r.top) / cyDib; 00053 for(register int j = 0; j <= ny; j++) 00054 { 00055 yOffset = j * cyDib; 00056 for(register int i = 0; i <= nx; i++) 00057 DIBBlt(hdc, i * cxDib, yOffset, cxDib, cyDib, hDIB, 0, 0, SRCCOPY); 00058 } 00059 } 00060 break; 00061 } 00062 } 00063 hOldPal = SelectPalette(hdc, hOldPal, FALSE); 00064 DeleteObject(hOldPal); 00065 } 00066 00067 BOOL DIBVIEW::LoadDIB(LPCSTR szDib) 00068 { 00069 // Attempt to load user's chosen background tile 00070 if(ReadDib(szDib)) 00071 { 00072 cxDib = (int)GetDibWidth(); 00073 cyDib = (int)GetDibHeight(); 00074 GlobalUnlockPtr(GetDib()); 00075 return TRUE; 00076 } 00077 return FALSE; 00078 } 00079