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; bool bRet = false;
switch (imageType) // attempt load image from the ResourceMap.
{ const TBitmap* pBmp = CCFileUtils::getBitmapByResName(strPath.c_str());
case kImageFormatPNG: if (pBmp)
// use libpng load image {
bRet = loadPng(strPath.c_str()); initWithBitmap(pBmp);
break; bRet = true;
case kImageFormatJPG: }
bRet = loadJpg(strPath.c_str());
break;
default:
// unsupported image type
bRet = false;
break;
}
if (!bRet) if (!bRet)
{ {
// attempt load image from the ResourceMap when can't find the image file. // can't find in the ResourceMap,find in hardware
const TBitmap* pBmp = CCFileUtils::getBitmapByResName(strPath.c_str()); switch (imageType)
if (pBmp) {
{ case kImageFormatPNG:
initWithBitmap(pBmp); // use libpng load image
bRet = true; bRet = loadPng(strPath.c_str());
} break;
case kImageFormatJPG:
bRet = loadJpg(strPath.c_str());
break;
default:
// unsupported image type
bRet = false;
break;
}
} }
return bRet; return bRet;