| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var EXIF_MARK_SOI = 0xffd8; // Start of image data. | 5 var EXIF_MARK_SOI = 0xffd8; // Start of image data. |
| 6 var EXIF_MARK_SOS = 0xffda; // Start of "stream" (the actual image data). | 6 var EXIF_MARK_SOS = 0xffda; // Start of "stream" (the actual image data). |
| 7 var EXIF_MARK_SOF = 0xffc0; // Start of "frame" | 7 var EXIF_MARK_SOF = 0xffc0; // Start of "frame" |
| 8 var EXIF_MARK_EXIF = 0xffe1; // Start of exif block. | 8 var EXIF_MARK_EXIF = 0xffe1; // Start of exif block. |
| 9 | 9 |
| 10 var EXIF_ALIGN_LITTLE = 0x4949; // Indicates little endian exif data. | 10 var EXIF_ALIGN_LITTLE = 0x4949; // Indicates little endian exif data. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 | 58 |
| 59 if (filePos == 0) { | 59 if (filePos == 0) { |
| 60 // First slice, check for the SOI mark. | 60 // First slice, check for the SOI mark. |
| 61 var firstMark = this.readMark(br); | 61 var firstMark = this.readMark(br); |
| 62 if (firstMark != EXIF_MARK_SOI) | 62 if (firstMark != EXIF_MARK_SOI) |
| 63 throw new Error('Invalid file header: ' + firstMark.toString(16)); | 63 throw new Error('Invalid file header: ' + firstMark.toString(16)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 var self = this; | 66 var self = this; |
| 67 function reread(opt_offset, opt_bytes) { | 67 var reread = function(opt_offset, opt_bytes) { |
| 68 self.requestSlice(file, callback, errorCallback, metadata, | 68 self.requestSlice(file, callback, errorCallback, metadata, |
| 69 filePos + br.tell() + (opt_offset || 0), opt_bytes); | 69 filePos + br.tell() + (opt_offset || 0), opt_bytes); |
| 70 } | 70 }; |
| 71 | 71 |
| 72 while (true) { | 72 while (true) { |
| 73 if (!br.canRead(4)) { | 73 if (!br.canRead(4)) { |
| 74 // Cannot read the mark and the length, request a minimum-size slice. | 74 // Cannot read the mark and the length, request a minimum-size slice. |
| 75 reread(); | 75 reread(); |
| 76 return; | 76 return; |
| 77 } | 77 } |
| 78 | 78 |
| 79 var mark = this.readMark(br); | 79 var mark = this.readMark(br); |
| 80 if (mark == EXIF_MARK_SOS) | 80 if (mark == EXIF_MARK_SOS) |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 return { | 362 return { |
| 363 scaleX: ExifParser.SCALEX[index], | 363 scaleX: ExifParser.SCALEX[index], |
| 364 scaleY: ExifParser.SCALEY[index], | 364 scaleY: ExifParser.SCALEY[index], |
| 365 rotate90: ExifParser.ROTATE90[index] | 365 rotate90: ExifParser.ROTATE90[index] |
| 366 }; | 366 }; |
| 367 } | 367 } |
| 368 return null; | 368 return null; |
| 369 }; | 369 }; |
| 370 | 370 |
| 371 MetadataDispatcher.registerParserClass(ExifParser); | 371 MetadataDispatcher.registerParserClass(ExifParser); |
| OLD | NEW |