Hi,
I want to access the device’s library and pick a image/photo file from it and use it as a CCSprite in the app. I got the following to access the files:
CCImage * img = new CCImage;
CCTexture2D* tex = new CCTexture2D;
auto task = create_task(Windows::Storage::KnownFolders::PicturesLibrary->GetFilesAsync(Windows::Storage::Search::CommonFileQuery::OrderBySearchRank));
task.then([img,tex](Windows::Foundation::Collections::IVectorView^ files)
{
CCLog("num of files detected %d",files->Size);
Platform::String^ pathstr = files->GetAt(0)->Path;
char sstrpath[1024];
wcstombs(sstrpath,pathstr->Data(),1024);
img->initWithImageFile(sstrpath,CCImage::EImageFormat::kFmtJpg);
tex->initWithImage(img);
}
);
CCSprite* spr = CCSprite::spriteWithTexture(tex);
this->addChild(spr,0);
when i do this, the CCImage and CCTexture2D could not be created. sstrpath shows to contain something like “C:UsersmyNamePicturesCamera Rollpicture001.jpg”. Can I get some advice? I know its possible to get a filestream an then create a BitmapImage object from it, I still need to know if there’s a way to create a CCImage or CCTexture2d or CCSprite from it…