我试图从存储卡中恢复图像,但我得到的大部分图像都损坏了。谁能告诉我为什么会出现这种情况?

问题描述 投票:0回答:1
while( !feof(card))
{
  FILE *f1=fopen(gp[i],"a");                            //Opens a new file to store the bytes in
  fread(buffer1, sizeof(BYTE), 512, card);              //Reads a set of bytes from the card
  if (buffer1[0] == 0xff && buffer1[1] == 0xd8 && buffer1[2] == 0xff && buffer1[3]/0x10==0x0e)  //Checks whether the first 4 bytes match the start of a jpg
  {

      fwrite(buffer1, sizeof(BYTE), 512, f1);               //Writes the bytes on to the opened file
      fread(buffer1, sizeof(BYTE), 512, card);              //Reads the next set of bytes from the card

      while (buffer1[0] != 0xff && buffer1[1] != 0xd8 && buffer1[2] != 0xff && buffer1[3]/0x10!=0x0e)   //Repeats the below process till we find the start of a new jpg
      {
      fwrite(buffer1, sizeof(BYTE), 512, f1);               //Writes the bytes on to the opened file
      fread(buffer1, sizeof(BYTE), 512, card);              //Reads the next set of bytes from the card
      }
      fclose(f1);
      i++;
  }
c cs50 recovery
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.