如何通过用C++编写的代码将位图图像保存在Android设备中
How to save Bitmap Image in Android device through code written in C++
我正在尝试在Android中保存位图图像,但通过C++功能。我使用流吗?如果是,我应该为创建的ofstream对象提供什么路径?
std::ofstream bmpF;
bmpF.open(<Android Path?>, std::ofstream::binary | std::ofstream::out);
文件名可以是安卓项目中的任何路径。你可以通过 jni 层传递它,并在 java 中从 : context.getFilesDir(( +"/"+
至于 ofstream 的使用:您可以选择以与普通 c/c++ 项目相同的方式写入文件。
文本文件示例
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("//storage//emulated//0//pictures//name.bmp",
std::ofstream::binary | std::ofstream::out(;相关文章:
- C++模板来检查友元函数的存在
- 在全局变量中保存类的实例以重新创建类(创建"backup")
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 既然存在危险,为什么项目要使用-I include开关
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- 我们可以访问一个不存在的联盟的成员吗
- C++:对不存在的命名空间使用命名空间指令
- 将字符指针十六进制转换为字符串并保存在文本文件C++中
- 在没有定义返回类型的函数中返回布尔值,并将结果保存在无错误的char编译中-为什么
- EvtExportLogneneneba API正在将远程计算机的事件日志保存到远程PC本身.如何将其保存到主机
- C++quit()函数中可能存在作用域问题
- C++擦除(如果存在)
- 在C++中将类(带有Vector成员)保存为二进制文件
- 使用导入的图像保存在 QT 中的 QLabel 中,保存 GUI 的状态
- 阵列不能两次将相同的名称保存,当要添加新字符串时,程序应检查以查看该名称是否已经存在
- 方法,该方法调用所有基类的同名方法(如果存在),并将返回值保存到列表中
- 什么设计模式将数据部分保存在持久存储 (SQL) 中,部分保存在 RAM(内存)中
- 是否存在可用于保存任何枚举值的整型?
- 将对象指针保存在 STL 容器中是否比将对象本身保存更好
- 从控制台保存信息,然后重新打开时,信息仍然存在