|
-
July 5th, 2012, 08:43 AM
#1
printer not showing the image properly.
Below is the code that prints image but image width and height is very less.
Suppose if my image width = 900 and height=600 then it prints the image with width around 60 and height around 70 . What can be problem ?
DWORD CDemo1Dlg: oPrintJob(LPTSTR szPrinterName)//szPrinterName is path of the printer in the network
{
DWORD dwError = 0;
TCHAR szJobName[128] = {0};
HDC hDC = 0;
DOCINFO DocInfo;
BITMAPINFO BmpInfo;
int nRet = 0;
HBITMAP hBmp24 = 0;
BITMAP Bmp24 = {0};
LOGFONT LogFont = {0};
HFONT hFont = 0,
hDefFont = 0;
if ( !m_Bmp24Name.IsEmpty() )
{
hBmp24 = (HBITMAP) LoadImage(0, (LPCTSTR)m_Bmp24Name, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
dwError = GetLastError();
GetObject(hBmp24, sizeof(BITMAP), &Bmp24);
}
hDC = CreateDC(_T("WINSPOOL"), szPrinterName, NULL, 0);
if ( dwError )
return dwError;
//4. StartDoc
memset(&DocInfo, 0, sizeof(DOCINFO));
DocInfo.cbSize = sizeof(DOCINFO);
lstrcpy(szJobName, _T("Test"));
DocInfo.lpszDocName = szJobName;
nJobId = ::StartDoc(hDC, &DocInfo);
//5. StartPage
nRet = ::StartPage(hDC);
//6.b Draw anything you want on page between ::StartPage and ::EndPage
if ( Bmp24.bmBits )
{
memset(&BmpInfo, 0, sizeof(BITMAPINFO));
BmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
BmpInfo.bmiHeader.biWidth = Bmp24.bmWidth;
BmpInfo.bmiHeader.biHeight = Bmp24.bmHeight;
BmpInfo.bmiHeader.biPlanes = Bmp24.bmPlanes;
BmpInfo.bmiHeader.biBitCount = Bmp24.bmBitsPixel * Bmp24.bmPlanes;
BmpInfo.bmiHeader.biCompression = BI_RGB;
nRet = StretchDIBits(hDC, 0, 0, Bmp24.bmWidth, Bmp24.bmHeight, 0, 0, Bmp24.bmWidth, Bmp24.bmHeight, Bmp24.bmBits, &BmpInfo, DIB_RGB_COLORS, SRCCOPY);
}
//7. If page drawing is finished, set to end page
nRet = ::EndPage(hDC);
//8. If job done, set end of the job
nRet = ::EndDoc(hDC);
//release image object
if ( hBmp24 )
DeleteObject(hBmp24);
: eleteDC(hDC);
return 0;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|