Using CImage i can print any kind of image. But when i try to print 4*6 image then images get distorted(stretch or shrink). What should i do?.
Following is the code .

void PrinterJob:rint(CString printerName,CString imageName,int width, int height)
{
TCHAR szJobName[128] = {0};
HDC hDC = 0;
DOCINFO DocInfo;
int nJobId = 0;
int nRet = 0;
CImage image;
//2. CreateDC
hDC = CreateDC(_T("WINSPOOL"), printerName, NULL, 0);
//4. StartDoc
memset(&DocInfo, 0, sizeof(DOCINFO));
DocInfo.cbSize = sizeof(DOCINFO);

lstrcpy(szJobName, _T("Test"));
DocInfo.lpszDocName = szJobName;

nJobId = ::StartDoc(hDC, &DocInfo);

nRet = ::StartPage(hDC);
if(nRet)
{
image.Load(imageName);
int xDpi =GetDeviceCaps(hDC, LOGPIXELSX);// to get the dpi
int yDpi = GetDeviceCaps(hDC, LOGPIXELSY);
printResult = image.StretchBlt(hDC,250,200,xDpi*width,yDpi*height, 0, 0, image.GetWidth(), image.GetHeight(), 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);
:eleteDC(hDC);

}