- uint32_t backup_size = 0;
- fread(&backup_size, sizeof(uint32_t), 1, fp);
- fseek(fp, backup_size, SEEK_CUR);
- len += sizeof(backup_size) + backup_size; // account for 'backup image' and its size
- printf(" orig:%u: %u\n", n, backup_size);
+ char name[256] = {0};
+ sprintf(name, "%s/img%u.jpg", options->export, n);
+
+ FILE *fp2 = fopen(name, "wb");
+ if (fp2 == NULL) {
+ perror("fopen image file");
+ exit(1);
+ }
+ fseek(fp, pos, SEEK_SET);
+ size_t len = fcopy(fp, fp2, image_size);
+ fclose(fp2);
+ // For revision > 2 we have the size of the 'original' image if present and the image data.
+ if (hdr.revision > 2)
+ {
+ uint32_t backup_size = 0;
+ fread(&backup_size, sizeof(uint32_t), 1, fp);
+ fseek(fp, backup_size, SEEK_CUR);
+ len += sizeof(backup_size) + backup_size; // account for 'backup image' and its size
+ printf(" orig:%u: %u\n", n, backup_size);
+ }