to the manifest but even with that, my app crashes when I try to launch those methods, i have also tried to get the path from @ Environment.getExternalStorageDirectory();@ and add it to the saveBuffer method, but it also crashes. any solution? i can add my code if that helps. thanks
Hi again, finally I achieved to save the image into the sdCard, not sure why the saveBuffer method didn’t work for me, so after getting the path for the sdCard, I just added the saveBuffer code into my class :
CCImage *pImage = new CCImage(); tex->getUIImageFromBuffer(pImage, 0,0, 0, 0); pImage->saveToFile(ossFile.str().c_str());
hello, Jon.
i think there are two points you may check:
firstly, have you render what you want in the texture?
its architecture looks like this:
rend~~>begin;
sprite~~>visit();
rend->end();
secondly, saveBuffer has two override functions as follows, one is for filepath, and the other is for filename, do you use it correctly?
/* saves the texture into a file/
// para szFilePath the absolute path to save
// para x,y the lower left corner coordinates of the buffer to save
// pare nWidth,nHeight the size of the buffer to save
// when nWidth = 0 and nHeight = 0, the image size to save equals to buffer texture size
bool saveBuffer(const char szFilePath, int x = 0, int y = 0, int nWidth = 0, int nHeight = 0);
/* saves the texture into a file. put format at the first argument, or ti will be overloaded with
* saveBuffer(const char szFilePath, int x = 0, int y = 0, int nWidth = 0, int nHeight = 0)/
// para name the file name to save
// para format the image format to save, here it supports kCCImageFormatPNG and kCCImageFormatJPG */
// para x,y the lower left corner coordinates of the buffer to save
// pare nWidth,nHeight the size of the buffer to save
// when nWidth = 0 and nHeight = 0, the image size to save equals to buffer texture size
bool saveBuffer(int format, const char *name, int x = 0, int y = 0, int nWidth = 0, int nHeight = 0);
hello, Jon.
i think there are two points you may check:
firstly, have you render what you want in the texture?
its architecture looks like this:
rend~~>begin;
sprite~~>visit();
rend->end();
>
>
secondly, saveBuffer has two override functions as follows, one is for filepath, and the other is for filename, do you use it correctly?
/** saves the texture into a file */
// para szFilePath the absolute path to save
// para x,y the lower left corner coordinates of the buffer to save
// pare nWidth,nHeight the size of the buffer to save
// when nWidth = 0 and nHeight = 0, the image size to save equals to buffer texture size
bool saveBuffer(const char *szFilePath, int x = 0, int y = 0, int nWidth = 0, int nHeight = 0);
/** saves the texture into a file. put format at the first argument, or ti will be overloaded with
* saveBuffer(const char *szFilePath, int x = 0, int y = 0, int nWidth = 0, int nHeight = 0) */
// para name the file name to save
// para format the image format to save, here it supports kCCImageFormatPNG and kCCImageFormatJPG */
// para x,y the lower left corner coordinates of the buffer to save
// pare nWidth,nHeight the size of the buffer to save
// when nWidth = 0 and nHeight = 0, the image size to save equals to buffer texture size
bool saveBuffer(int format, const char *name, int x = 0, int y = 0, int nWidth = 0, int nHeight = 0);
but, how can i save it as a image on iphone to show it in the device galery?
it saves the images to app documents and there is no access from device menu.
If you want to save it to the iPhone, the best way is to create a objective-c proxy which calls to UIImageWriteToSavedPhotosAlbum(yourUIImage, nil, nil, nil);