CCImage image;
unsigned long nSize;
char a[]=”15757775232226656.jpg”;
unsigned char* pBuffer = CCFileUtils::sharedFileUtils()->getFileData(a, “rb”, &nSize);
image.initWithImageData((void*)pBuffer, nSize, CCImage::kFmtJpg);
CC_SAFE_DELETE(pBuffer);
CCTexture2D* pTexture=CCTextureCache::sharedTextureCache()->addUIImage(&image,”key”);
CCSprite* tSprite=new CCSprite();
CCRect rect = CCRectZero;
rect.size = pTexture->getContentSize();
tSprite->initWithTexture(pTexture, rect);
tSprite->setPosition(ccp(size.width/2,size.height/2));
this->addChild(tSprite,1);
0 条评论。