我正在尝试使用 android ndk 中的 C 函数计算大型 bmp 文件的大小。我正在使用以下代码:-
int getSizeOfCapturedImage(char * imagePath) {
FILE *imageFile = fopen(imagePath, "rb");
long sizeOfImageFile = 0;
if (imageFile == NULL) {
printf("file not found!\n"); //handle error
return 1;
} else {
fseek(imageFile, 0, SEEK_END);
sizeOfImageFile = ftell(imageFile);
printf("size of ImageFile is %1dB\n", sizeOfImageFile);
fclose(imageFile);
}
return sizeOfImageFile;
}
但是,当 bmp 文件的大小大于 120 字节时,此功能无法正常工作。该文件以某种方式无法打开,并且文件指针 *imageFile 变为 NULL。
谁能告诉我为什么会这样和/或有另一种出路?