Board index » Visual Studio » CBrush(*CBitmap) Texture Brush Printing Issue.
|
Wilkster
|
CBrush(*CBitmap) Texture Brush Printing Issue.
Visual Studio323
Question is: What can I do to make sure that when printing in Landscape that a CBrush (Texture Brush) will not overlap, but tile correctly as it does in Portrait mode? Here is the sample code: //Temp Device COntext CDC dcTemp; CBitmap bmp; //Create the Bitmap Texture (nScaleFactor is global) bmp.CreateCompatibleBitmap(pDC,20*nScaleFactor,20*nScaleFactor); //Create compatible DC dcTemp.CreateCompatibleDC(pDC); //Select the Bitmap into the temp DC oldBMP = dcTemp.SelectObject(&bmp); //Draw the Bitmap Texture RECT rc; CBrush brushWhite(RGB(255,255,255)); dcTemp.GetClipBox(&rc); //Make the actual Texture pattern. In this case, just a circle dcTemp.FillRect(&rc, &brushWhite); dcTemp.Ellipse(&rc); dcTemp.SelectObject(oldBMP); //Create a Texture brush using the Bitmap above CBrush brush4(&bmp); //Select the Texture Brush in the current DC pOldBrush = pDC->SelectObject(&brush4); //Paint with Tecture bitmap (200X200 Square) pDC->Rectangle(100*nScaleFactor,100*nScaleFactor,300*nScaleFactor,300*nScale Factor); This prints fine in "Portrait" mode, but in Landscape, the texture is not tiled correctly. There is overlapping of the texture. Please NOTE: 'nScaleFactor' is used to scale the draw such that it prints the right size on the printer (is 1 when in running mode, and ranges from 2 to 8 when printing depending on the DPI of printer used) This is adjusted in the OnPrint() Method: //m_rcPaper is a CRect sized to a 8.5" X 11" paper (850,1100) m_fZoomFactor = (float)pInfo->m_rectDraw.Width()/m_rcPaper.Width(); Thanks, Joe - |
