StretchDIBits fit into paper
-
I would like to make my program to fit into paper when printing out. I know we should deal with that with this function but I am not sure about parameter Does anyone know what to put? BITMAPINFOHEADER *pBMI = (BITMAPINFOHEADER*)(LPVOID)lock; int nColors = 0; if( pBMI->biBitCount <= 8 ) nColors = ( 1<< pBMI->biBitCount ); if( b_PrintFit ) { ::StretchDIBits( pDC->GetSafeHdc( ), pInfo->m_rectDraw.left, pInfo->m_rectDraw.top, pBMI->biWidth, pBMI->biHeight, 0, 0, pBMI->biWidth, pBMI->biHeight, (LPBYTE)pBMI + (pBMI->biSize + nColors * sizeof(RGBQUAD)), (BITMAPINFO*)pBMI, DIB_RGB_COLORS, SRCCOPY); Thanks shin
-
I would like to make my program to fit into paper when printing out. I know we should deal with that with this function but I am not sure about parameter Does anyone know what to put? BITMAPINFOHEADER *pBMI = (BITMAPINFOHEADER*)(LPVOID)lock; int nColors = 0; if( pBMI->biBitCount <= 8 ) nColors = ( 1<< pBMI->biBitCount ); if( b_PrintFit ) { ::StretchDIBits( pDC->GetSafeHdc( ), pInfo->m_rectDraw.left, pInfo->m_rectDraw.top, pBMI->biWidth, pBMI->biHeight, 0, 0, pBMI->biWidth, pBMI->biHeight, (LPBYTE)pBMI + (pBMI->biSize + nColors * sizeof(RGBQUAD)), (BITMAPINFO*)pBMI, DIB_RGB_COLORS, SRCCOPY); Thanks shin
10th parameter of StretchDIBits should be a pointer to a buffer containing RGB data of bitmap you want to print. For eg. CBitmap bmp; bmp.LoadBitmap(IDB_SOMEBITMAP); BITMAP bm; bmp.GetBitmap(&bm); bm.bmBits is the pointer you need. Other parameters may be right or wrong cause I dont know what they mean in your program. By the way, for printing a bitmap you should to create a printer DC and to calculate destination rectangle with paper resolution. For more info see MSDN!