none
Graphis::GrawImage(绘制大图,7021*9999)时经常出错,求分析下面代码有什么问题? RRS feed

  • 问题

  • int nWidth = pImage->GetWidth();
    int nHeight = pImage->GetHeight();

    if (nWidth == 0 || nHeight == 0)
    return NULL;

    Status status = Ok;

    Bitmap* pNewBitmap = new Bitmap(nWidth, nHeight);
    status = pNewBitmap->GetLastStatus();
    if (status != Ok) {
    if (status == OutOfMemory)
    PrintLog(_T("[CImageUtil::CloneEx2] new Bitmap outofmemory......"));
    else
    PrintLog(_T("[CImageUtil::CloneEx2] new Bitmap failure(%d)......"), status);
    }
    if (pNewBitmap != NULL)
    {
    Graphics gs(pNewBitmap);
    gs.SetInterpolationMode(InterpolationModeHighQuality);
    gs.SetSmoothingMode(SmoothingModeAntiAlias);
    status = gs.DrawImage(pImage, 0, 0, nWidth, nHeight);
    if (Ok == status)
    {
    return pNewBitmap;
    }
    else
    {
    delete pNewBitmap;
    if (status == OutOfMemory)
    PrintLog(_T("[CImageUtil::CloneEx2] new Bitmap outofmemory......"));
    else
    PrintLog(_T("[CImageUtil::CloneEx2] gs.DrawImage failure(%d)......"), status);
    }
    }

    以上代码status = gs.DrawImage(pImage, 0, 0, nWidth, nHeight);这句绘制大图的时候经常返回Win32Error求问是怎么回事?大图绘制耗内存又耗时间如何解决?还有当使用内存占用1G多的时候经常Graphics::DrawImage也经常会出问题求解答!

    2017年1月11日 8:37