#include "T2BitImage.h" #include "T2People.h" #include "T2SilhouettePane.h" #include "UT2Coordinate.h" #include T2SilhouettePane::T2SilhouettePane(T2TowerDoc* towerDoc, T2ImageObj* imageObj, CPalette* palette) : T2DlgItem(towerDoc, imageObj, palette) { mPeople = NULL; mHasCustomColor = false; mA0 = 0; mSilhouetteType = 0; m8C = 0; m90 = 0; } /*virtual*/ T2SilhouettePane::~T2SilhouettePane() { } /*virtual*/ void T2SilhouettePane::DrawSelf(CDC* dc) { CRect clientRect; GetClientRect(clientRect); if (mPeople && !clientRect.IsRectEmpty()) { dc->FillRect(clientRect, CBrush::FromHandle((HBRUSH) GetStockObject(WHITE_BRUSH))); clientRect.DeflateRect(2, 2); int origColor = mPeople->mColor; if (mHasCustomColor) mPeople->mColor = mCustomColor; CRect imageRect(0, 0, mPeople->GetWidth() * 8, 36); T2BitImage *image = new T2BitImage(imageRect); image->Clear(0); mPeople->Draw(image, imageRect); CRect rect3 = imageRect; rect3.top += UT2Coordinate::CalcRoofThick(0); rect3.bottom -= UT2Coordinate::CalcFloorThick(0); float ratio = min(float(clientRect.Width()) / float(rect3.Width()), float(clientRect.Height()) / float(rect3.Height())); if (ratio < 1.0) ratio = 1.0f; CRect rect4(0, 0, rect3.Width() * ratio, rect3.Height() * ratio); rect4.OffsetRect( clientRect.left + (clientRect.Width() - rect4.Width()) / 2, clientRect.top + (clientRect.Height() - rect4.Height()) / 2 ); StretchDIBits( dc->m_hDC, rect4.left, rect4.top, rect4.Width(), rect4.Height(), rect3.left, rect3.bottom + 1, rect3.Width(), -rect3.Height(), image->mData, (BITMAPINFO *) &image->mBitmap, DIB_PAL_COLORS, SRCCOPY); delete image; mPeople->mColor = origColor; } } /*virtual*/ BOOL T2SilhouettePane::OnT2DlgItemEraseBkgnd(CDC* dc) { int save = dc->SaveDC(); dc->SelectPalette(mPalette, false); dc->RealizePalette(); if (!mPeople) return false; DrawSelf(dc); dc->RestoreDC(save); return true; } /*virtual*/ BOOL T2SilhouettePane::OnCreate(CREATESTRUCT* cs) { return T2DlgItem::OnCreate(cs); } void T2SilhouettePane::SetPeople(T2People* people) { mPeople = people; InvalidateRect(NULL); }