我遇到了一个非常奇怪的问题。
代码如下:
::boost::shared_ptr<CQImageFileInfo> pInfo=CQUserViewDataManager::GetInstance()->GetImageFileInfo(nIndex);
Image* pImage=pInfo->m_pThumbnail;
if(pImage==NULL)
pImage=m_pStretchedDefaultThumbImage;
else
{
//
int sourceWidth = pInfo->GetWidth();
int sourceHeight = pInfo->GetHeight();
int destX = 0,
destY = 0;
float nPercent = 0;
float nPercentW = ((float)GetThumbImageWidth()/(float)sourceWidth);;
float nPercentH = ((float)GetThumbImageHeight()/(float)sourceHeight);
if(nPercentH < nPercentW)
{
nPercent = nPercentH;
destX = (int)((GetThumbImageWidth() - (sourceWidth * nPercent))/2);
}
else
{
nPercent = nPercentW;
destY = (int)((GetThumbImageHeight() - (sourceHeight * nPercent))/2);
}
int destWidth = (int)(sourceWidth * nPercent);
int destHeight = (int)(sourceHeight * nPercent);
rcShowImage=CRect(rc.left+destX, rc.top+destY,rc.left+destX+destWidth,rc.top+destY+destHeight);
}
ASSERT(pImage != NULL); // passed assertion...
graphics.DrawImage(pImage,rcShowImage.left,rcShowImage.top,
rcShowImage.Width(),rcShowImage.Height()); // problem happened here.
我收到以下异常:
First-chance exception at 0x004095b0 in ec.exe: 0xC0000005: Access violation reading location 0xfeeefef2.
Unhandled exception at 0x004095b0 in ec.exe: 0xC0000005: Access violation reading location 0xfeeefef2.
我已经检查了pImage
,我确定什么时候graphics.DrawImage
被调用,它不是NULL
。
- 为什么会出现这样的问题?
- 是什么
0xfeeefef2
?