how to read or write a file in BMP? [solved] | developer.brewmp.com how to read or write a file in BMP? [solved] | developer.brewmp.com

Developer

how to read or write a file in BMP? [solved]

Forums:

how to read or write a file in BMP? anyone can help? thanks

Hi,
You can do this in the same as in Brew with the help of IFILEMGR and IFILE interfaces.
Regards
Priya

Hi,
You can do this in the same as in Brew with the help of IFILEMGR and IFILE interfaces.
Regards
Priya

IFILEMGR and IFILE are deprecated APIS.
you can use IFileSystem2 and IFilePort1.
Quote:
if(IEnv_CreateInstance(ppiEnv,AEECLSID_FileSystem2 ,(void * *) &pIFilesys)!= AEE_SUCCESS)
{
LOGE("AEECLSID_FileSystem2 create instance failed");
return FALSE;
}
if(IFileSystem2_Open(pIFilesys, path, FS_CAP_RDONLY, &file)!= AEE_SUCCESS)
{
LOGE("IFileSystem2_Open failed while opening a file");
//release filesystem2
IFileSystem2_Release(pIFilesys);
return FALSE;
}
/* get the file length */
fileLength=umap_fsize(file);
if(fileLength<=0) {
LOGE("umap_fsize error,fileLength <= 0 ");
IFilePort1_Release(file);
IFileSystem2_Release(pIFilesys);
return FALSE;
}
/* allocate the memory to hold the file data */
p=uprv_malloc((size_t)fileLength);
if(p==NULL) {
LOGE("uprv_malloc err,failed to allocate memory %d bytes",fileLength);
IFilePort1_Release(file);
IFileSystem2_Release(pIFilesys);
return FALSE;
}
/* read the file */
if(AEE_SUCCESS!=IFilePort1_Read(file,p,(int)fileLength,&bufread)&& fileLength!=bufread) {
LOGE("IFilePort1_Read err, could not read from file");
uprv_free(p);
IFilePort1_Release(file);
IFileSystem2_Release(pIFilesys);
return FALSE;
}
IFilePort1_Release(file);
IFileSystem2_Release(pIFilesys);
add AEECLSID_FileSystem2 in dependency

IFILEMGR and IFILE are deprecated APIS.
you can use IFileSystem2 and IFilePort1.
Quote:
if(IEnv_CreateInstance(ppiEnv,AEECLSID_FileSystem2 ,(void * *) &pIFilesys)!= AEE_SUCCESS)
{
LOGE("AEECLSID_FileSystem2 create instance failed");
return FALSE;
}
if(IFileSystem2_Open(pIFilesys, path, FS_CAP_RDONLY, &file)!= AEE_SUCCESS)
{
LOGE("IFileSystem2_Open failed while opening a file");
//release filesystem2
IFileSystem2_Release(pIFilesys);
return FALSE;
}
/* get the file length */
fileLength=umap_fsize(file);
if(fileLength<=0) {
LOGE("umap_fsize error,fileLength <= 0 ");
IFilePort1_Release(file);
IFileSystem2_Release(pIFilesys);
return FALSE;
}
/* allocate the memory to hold the file data */
p=uprv_malloc((size_t)fileLength);
if(p==NULL) {
LOGE("uprv_malloc err,failed to allocate memory %d bytes",fileLength);
IFilePort1_Release(file);
IFileSystem2_Release(pIFilesys);
return FALSE;
}
/* read the file */
if(AEE_SUCCESS!=IFilePort1_Read(file,p,(int)fileLength,&bufread)&& fileLength!=bufread) {
LOGE("IFilePort1_Read err, could not read from file");
uprv_free(p);
IFilePort1_Release(file);
IFileSystem2_Release(pIFilesys);
return FALSE;
}
IFilePort1_Release(file);
IFileSystem2_Release(pIFilesys);
add AEECLSID_FileSystem2 in dependency

Thank you, priya.prakash and manju ,my problem has been sovled.

Thank you, priya.prakash and manju ,my problem has been sovled.