Fix to allow the correct saving of images on iOS when using a virtual file system (#369)

* Fix to allow the correct saving of images on iOS when using a virtual file system

* Add missing import for FileUtils
This commit is contained in:
RH 2021-06-03 04:34:02 +10:00 committed by GitHub
parent 5a6045ab19
commit 3c49c07465
1 changed files with 4 additions and 1 deletions

View File

@ -25,6 +25,7 @@ THE SOFTWARE.
****************************************************************************/
#import "platform/CCImage.h"
#import "platform/CCCommon.h"
#import "platform/CCFileUtils.h"
#import <string>
#import <Foundation/Foundation.h>
@ -111,7 +112,9 @@ bool cocos2d::Image::saveToFile(const std::string& filename, bool isToRGB)
} else {
data = UIImageJPEGRepresentation(image, 1.0f);
}
[data writeToFile:[NSString stringWithUTF8String:filename.c_str()] atomically:YES];
auto outStream = FileUtils::getInstance()->openFileStream(filename, FileStream::Mode::WRITE);
outStream->write(data.bytes, data.length);
}
[image release];