I am not able to open the images properly, and here is my code
typedef uint8_t BYTE;
BYTE buffer[512];
char title[10];
int count =0;
FILE* fp = fopen("card.raw","r");
while(!feof(fp))
{
fseek(fp, sizeof(buffer), SEEK_CUR);
fread(&buffer,32,1,fp);
while (!(buffer[0] == 0xff && buffer[1] == 0xd8 && buffer[2] == 0xff && (buffer[3] == 0xe0 ||buffer[3] == 0xe1)))
{
fread(&buffer,32,1,fp);
}
sprintf(title, "%03d.jpg" ,count );
FILE* image = fopen(title, "a");
while (!(buffer[0] == 0xff && buffer[1] == 0xd8 && buffer[2] == 0xff && (buffer[3] == 0xe0 ||buffer[3] == 0xe1)))
{
fwrite(&buffer, 512, 1, image);
}
count ++;
fclose(image);
}
fclose(fp);
}