how to get sprite from sdcard path???


i want to get sprite from sdcard

path mnt/sdcard/img.png

my code …

const char* tempTex = “mnt/sdcard/img.png”;
stringstream ss;
string s;
ss << tempTex;
ss >> s;

CCImage img;
CCFileData data(s.c_str(),“rb”);

unsigned long nSize = data.getSize();
unsigned char* pBuffer = data.getBuffer();
image.initWithImageData((void**)pBuffer, nSize, CCImage::kFmtJpg);
CCTexture2D**texture = new CCTexture2D();

if( texture ) {
CCSprite *sprite = CCSprite::spriteWithTexture(texture);

run android

show error

Get data from file(assets//mnt/sdcard/img.png) failed!

please help me!


The path should be absolute path.
May be you should change the path to “/mnt/sdcard/img.png”.


I solved the problem.

I Use to fopen