I am completely stuck right now when it comes to implement:
Write 512 bytes until the new jpeg is found.
Could anyone give me idea how to implement this step?
Here is my code:
// Declare buffer array
BYTE buffer[512];
// Initializing JPEG image
int count = 0;
// Repeat until end of card
while(!feof(inptr))
{
// Read 512 bytes into buffer
fread(buffer, 512, 1, inptr);
// Find the beginning of JPEG image
if(buffer[0] == 0xff &&
buffer[1] == 0xd8 &&
buffer[2] == 0xff &&
(buffer[3] & 0xf0) == 0xe0)
{
char filename[8];
sprintf(filename, "%03i.jpg", count);
FILE *img = fopen(filename, "w");
// write 512 bytes until the new jpeg is found
fwrite(buffer, 512, 1, img);
count++;
fclose(img);
}
}