I'm trying to save a bitmap image in the Android but through C++ functionality. Do I use ofstream? And if yes, what path should I give for the ofstream object created?
std::ofstream bmpF;
bmpF.open(<Android Path?>, std::ofstream::binary | std::ofstream::out);
fileName can be any path in android project. You can pass it through jni layer and get same in java from : context.getFilesDir() +"/"+
As far as use of ofstream: you may choose to write to file in same way as you would in normal c/c++ project.
Text file example
void writeToFile( const char* fileName) {
FILE* fid = fopen(fileName, "w");
if (fid==NULL) {
printf("WriteVectorArt: couldn't open the file");
} else {
fprintf(fid, "SomeText to write");
fclose(fid);
}}
bmpF.open(“ //存储//仿真// 0 //图片//name.bmp”,std :: ofstream :: binary | std :: ofstream :: out);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.