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