This commit is contained in:
natural-law 2010-10-22 07:51:32 +00:00
parent 1d8b5d02a3
commit 419544ff45
1 changed files with 22 additions and 21 deletions

View File

@ -119,30 +119,31 @@ bool UIImage::initWithContentsOfFile(const string &strPath, tImageFormat imageTy
{
bool bRet = false;
switch (imageType)
{
case kImageFormatPNG:
// use libpng load image
bRet = loadPng(strPath.c_str());
break;
case kImageFormatJPG:
bRet = loadJpg(strPath.c_str());
break;
default:
// unsupported image type
bRet = false;
break;
}
// attempt load image from the ResourceMap.
const TBitmap* pBmp = CCFileUtils::getBitmapByResName(strPath.c_str());
if (pBmp)
{
initWithBitmap(pBmp);
bRet = true;
}
if (!bRet)
{
// attempt load image from the ResourceMap when can't find the image file.
const TBitmap* pBmp = CCFileUtils::getBitmapByResName(strPath.c_str());
if (pBmp)
{
initWithBitmap(pBmp);
bRet = true;
}
// can't find in the ResourceMap,find in hardware
switch (imageType)
{
case kImageFormatPNG:
// use libpng load image
bRet = loadPng(strPath.c_str());
break;
case kImageFormatJPG:
bRet = loadJpg(strPath.c_str());
break;
default:
// unsupported image type
bRet = false;
break;
}
}
return bRet;