/******************************************************************************************** > BOOL TipsDlg::DrawBitmap(ResourceID BitmapID, DocRect& RedrawRect) Author: Colin_Barfoot (Xara Group Ltd) <*****@*****.**> Created: 08/08/96 Inputs: BitmapID : the resource id of the bitmap to draw RedrawRect : the rectangle in which to draw it Returns: TRUE if drawn OK FALSE otherwise Purpose: Renders the given bitmap in the given rectangle ********************************************************************************************/ BOOL TipsDlg::DrawBitmap(ResourceID BitmapID, DocRect& RedrawRect) { OILBitmap *pOILBitmap = OILBitmap::Create(); if (pOILBitmap == NULL) { return FALSE; } if (!pOILBitmap->LoadBitmap(BitmapID)) { return FALSE; } // Centre the bitmap within the RedrawRect UINT32 bitmapWidth = pOILBitmap->GetRecommendedWidth(); UINT32 bitmapHeight = pOILBitmap->GetRecommendedHeight(); UINT32 xOffset = RedrawRect.lo.x + (RedrawRect.Width() - bitmapWidth) / 2; UINT32 yOffset = RedrawRect.lo.y + (RedrawRect.Height() - bitmapHeight) / 2; DocCoord lowCorner(xOffset, yOffset); DocRect bitmapRect(lowCorner, bitmapWidth, bitmapHeight); KernelBitmap bitmap(pOILBitmap, TRUE); // Now we need to create a temporary NodeBitmap, which we will // use to render the bitmap preview. NodeBitmap* dummyNode = new NodeBitmap(); if (dummyNode == NULL) { return FALSE; } // Set the NodeBitmap path to be our RedrawRect and attach the Bitmap to it. dummyNode->SetUpPath(); dummyNode->CreateShape(bitmapRect); dummyNode->GetBitmapRef()->SetBitmap(&bitmap); // Now render the bitmap preview dummyNode->Render(m_pRenderer); delete dummyNode; // All OK return TRUE; }