24 #include "../base.hpp" 26 #include "../util/math.hpp" 39 return (data[0] << 8) + (data[1]);
41 return (data[1] << 8) + (data[0]);
54 return (data[0] << 24) + (data[1] << 16) +
55 (data[2] << 8) + (data[3]);
57 return (data[3] << 24) + (data[2] << 16) +
58 (data[1] << 8) + (data[0]);
69 bool checkTag(
unsigned char tag[2],
unsigned short tag_r,
bool bMotorola)
71 unsigned char tag_ref[2];
72 tag_ref[0] = (tag_r >> 8) & 0x00ff;
73 tag_ref[1] = tag_r & 0x00ff;
77 bRet = (tag[0] == tag_ref[0]) && (tag[1] == tag_ref[1]);
79 bRet = (tag[1] == tag_ref[0]) && (tag[0] == tag_ref[1]);
91 int getTagID(
unsigned char tag[2],
bool bMotorola)
93 if(
checkTag(tag, 0x829a, bMotorola)) {
97 if(
checkTag(tag, 0x829d, bMotorola)) {
101 if(
checkTag(tag, 0x8827, bMotorola)) {
105 if(
checkTag(tag, 0x9202, bMotorola)) {
109 if(
checkTag(tag, 0x920a, bMotorola)) {
188 char *tmp =
new char[length];
189 fread(tmp, 1, length, file);
190 std::string str(tmp);
206 for(
int i = 0; i < length; i++) {
207 str += (char) data[i];
221 unsigned char val0[4];
222 fread(val0, 1, 4, file);
224 unsigned char val1[4];
225 fread(val1, 1, 4, file);
230 return float(num) / float(denum);
252 FILE *file = fopen(name.c_str(),
"rb");
254 unsigned char buf[2];
255 fread(buf, 1, 2, file);
261 unsigned char buf2[2];
266 fread(buf2, 1, 2, file);
269 unsigned char len[2];
270 fread(&len, 1, 2, file);
273 length = (len[0] << 8) + (len[1]);
280 fseek(file, length - 2, SEEK_CUR);
290 unsigned char buf6[6];
291 fread(buf6, 1, 6, file);
293 if(buf6[0] != 0x45 || buf6[1] != 0x78 ||
294 buf6[2] != 0x69 || buf6[3] != 0x66 ||
295 buf6[4] != 0x00 || buf6[5] != 0x00) {
305 fread(buf2, 1, 2, file);
306 bool bMotorola = (buf2[0] == 0x4d) && (buf2[1] == 0x4d);
308 fread(buf2, 1, 2, file);
311 if(!
checkTag(buf2, 0x002a, bMotorola)) {
316 unsigned char buf4[4];
317 fread(buf4, 1, 4, file);
320 bCheck = (buf4[0] == 0x00) && (buf4[1] == 0x00) &&
321 (buf4[2] == 0x00) && (buf4[3] == 0x08);
323 bCheck = (buf4[0] == 0x08) && (buf4[1] == 0x00) &&
324 (buf4[2] == 0x00) && (buf4[3] == 0x00);
333 fread(buf2, 1, 2, file);
339 unsigned int offset = 0;
340 for(
int i = 0; i < nIFD; i++) {
341 unsigned char tag[2];
342 fread(tag, 1, 2, file);
344 unsigned char data_format[2];
345 fread(data_format, 1, 2, file);
347 unsigned char num_components[4];
348 fread(num_components, 1, 4, file);
350 unsigned char data[4];
351 fread(data, 1, 4, file);
354 if(
checkTag(tag, 0x010f, bMotorola)) {
361 if(total_data_byte > 4) {
365 fgetpos(file, &tmp_pos);
366 fseek(file, offset, SEEK_CUR);
368 fsetpos(file, &tmp_pos);
375 if(
checkTag(tag, 0x8769, bMotorola)) {
380 unsigned char next_IFD[4];
381 fread(next_IFD, 1, 4, file);
387 fseek(file, offset, SEEK_CUR);
395 fread(buf2, 1, 2, file);
399 for(
int i = 0; i < nIFD; i++) {
400 unsigned char tag[2];
402 fread(tag, 1, 2, file);
404 unsigned char data_format[2];
405 fread(data_format, 1, 2, file);
407 unsigned char num_components[4];
408 fread(num_components, 1, 4, file);
410 unsigned char data[4];
411 fread(data, 1, 4, file);
419 float data_value = 0;
420 if(total_data_byte > 4) {
424 fgetpos(file, &tmp_pos);
427 fseek(file, offset, SEEK_CUR);
437 fsetpos(file, &tmp_pos);
461 info.
iso = data_value;
unsigned int twoByteToValue(unsigned char data[2], bool bMotorola)
twoByteToValue
Definition: exif.hpp:36
std::string readString(FILE *file, int length)
readString
Definition: exif.hpp:186
float aperture
Definition: exif.hpp:237
float exposureTime
Definition: exif.hpp:235
float iso
Definition: exif.hpp:238
unsigned int fourByteToValue(unsigned char data[4], bool bMotorola)
fourByteToValue
Definition: exif.hpp:51
float focal_length
Definition: exif.hpp:239
std::string readStringFromUChar(unsigned char *data, int length)
readStringFromUChar
Definition: exif.hpp:202
bool readEXIF(std::string name, EXIFInfo &info)
readEXIF
Definition: exif.hpp:250
int getBytesForComponents(int value)
getBytesForComponents
Definition: exif.hpp:121
int getTagID(unsigned char tag[2], bool bMotorola)
getTagID
Definition: exif.hpp:91
float fNumber
Definition: exif.hpp:236
Definition: bilateral_separation.hpp:25
std::string camera_maker
Definition: exif.hpp:241
float readUnsignedRational(FILE *file, bool bMotorola)
readUnsignedRational
Definition: exif.hpp:219
bool checkTag(unsigned char tag[2], unsigned short tag_r, bool bMotorola)
checkTag
Definition: exif.hpp:69