我想在c中读取图像,但在限制字节中,这意味着要读取n个字节,直到所有图像结束
FILE *stream ;
FILE *stream1;
stream= fopen(pFile, "rb");
//when stream still bytes in stream
do
{
numread = fread( stream1, sizeof( char ), 64, stream );
//treat the stream1
}
最佳答案
您基本上需要这样:
FILE *stream1;
stream1 = fopen(pFile, "rb");
if (stream1 == NULL)
{
printf("Failed to open file");
return 1;
}
int numread;
do
{
char buffer[64];
numread = fread(buffer, sizeof(char), 64, stream1);
// now buffer contains the 'numbytes' bytes you have read
} while (!feof(stream1)):
关于c - 我如何按块读取c中的图像文件?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40153837/