用了CImage类,Load进图片并Save,但时得到的图片的分辨率是96,怎么能改到300?
打算做一个排版的软件,保存Jpg有问题,代码如下:
CString strFilter;
CString strFileName;
CString strExection;
COLORREF color = RGB(255, 255, 255);
CBrush brush;
    CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
    LeftView* pLeftView = (LeftView*)pFrame->GetSplitterLeftWnd()->GetPane(0, 0);
    CImage tmpImage;
    
if(!brush.CreateSolidBrush(color))
return;
CRect rect;
rect.left = 0;
rect.top = 0;
rect.bottom = 4430;
rect.right = 2010;

    if(pLeftView->m_pImageNameList->GetSize() < 1)
    {
        if(!tmpImage.IsNull())
            tmpImage.Destroy();
        return;
    }
    CDC* pImageCDC = CDC::FromHandle(m_image.GetDC());
    //pImageCDC->SetViewportExt(2010*300/96, 4430*300/96);
    HDC hDC = pImageCDC->m_hDC;
    //pImageCDC->SetMapMode(MM_ANISOTROPIC);  
    pImageCDC->FillRect(&rect, &brush);
    CString strTemp;
    LeftBottomView* pView = (LeftBottomView*)pFrame->GetSplitterLeftWnd()-                              >GetPane(1, 0);
    TCHAR* str = new TCHAR(20);
    int lenth = pView->m_pMyEdit->GetWindowText(str, 20);
int index = 0;
POSITION pos;
pos = pLeftView->m_pImageNameList->GetHeadPosition();
while(index < pLeftView->m_pImageNameList->GetSize())
{
tmpImage.Load(pLeftView->m_pImageNameList->GetAt(pos).c_str());
for(int i = 0; i < 8; i++){
tmpImage.Draw(hDC, 40+(i%2)*(30+PHOTO_WIDTH_V) + index%2* 1000, 100+i/2*(45+PHOTO_HEIGHT_V)+ index/2 * 1430/*, PHOTO_WIDTH_V, PHOTO_HEIGHT_V*/);
MyDrawText(pImageCDC, 40+(i%2)*(30+PHOTO_WIDTH_V)+90+index%2* 1000, 100+i/2*(45+PHOTO_HEIGHT_V)+PHOTO_HEIGHT_V+index/2 * 1430, str);
}
pLeftView->m_pImageNameList->GetNext(pos);
index++;
}
CFileDialog dlg(FALSE, NULL, NULL, OFN_OVERWRITEPROMPT | OFN_EXPLORER, "File(*.jpg)|*.jpg||");
 
dlg.DoModal(); strExection= ".jpg";
strFileName = dlg.m_ofn.lpstrFile;
strFileName = strFileName + strExection;    if(strFileName == ".jpg")
        return;
m_image.Save(strFileName);

解决方案 »

  1.   

    就是想把一张jpg图片重复画八次,然后将重复后的保存成一张jpg图片,同时不能让其品质降低,也就是分辨率降低,原始图片是300dpi,而我输出的只是96dpi
      

  2.   

    GDI+是一个绘图库。如果你要一个图形处理库,去搜索CxImage
      

  3.   

    GDI+里的Image类能载入图片,Graphics类能画出图片,但是不能将Image载入的图片画成我想要的样子然后再保存下来
      

  4.   

    你是用CImage tmpImage load图片和绘制图片!
    你为什么用m_image.Save(strFileName)呢。
    改为
    tmpImage .Save(strFileName)试试吧。
      

  5.   

    lyg_zy(学无止境,宁静致远)
    试过的,也是不行,好像一和CDC绑定或是一载入图片就会使分辨率降低