| 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 // TODO:(kaznacheev) Share the EXIF constants with exif_parser.js | 5 // TODO:(kaznacheev) Share the EXIF constants with exif_parser.js |
| 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_SOI = 0xffd8; // Start of image data. | 7 var EXIF_MARK_SOI = 0xffd8; // Start of image data. |
| 8 var EXIF_MARK_EOI = 0xffd9; // End of image data. | 8 var EXIF_MARK_EOI = 0xffd9; // End of image data. |
| 9 | 9 |
| 10 var EXIF_MARK_APP0 = 0xffe0; // APP0 block, most commonly JFIF data. | 10 var EXIF_MARK_APP0 = 0xffe0; // APP0 block, most commonly JFIF data. |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 ExifEncoder.writeValue = function(bw, tag) { | 359 ExifEncoder.writeValue = function(bw, tag) { |
| 360 if (tag.format == 2) { // String | 360 if (tag.format == 2) { // String |
| 361 if (tag.componentCount != tag.value.length) { | 361 if (tag.componentCount != tag.value.length) { |
| 362 throw new Error( | 362 throw new Error( |
| 363 'String size mismatch for 0x' + Number(tag.id).toString(16)); | 363 'String size mismatch for 0x' + Number(tag.id).toString(16)); |
| 364 } | 364 } |
| 365 bw.writeString(tag.value); | 365 bw.writeString(tag.value); |
| 366 } else { // Scalar or rational | 366 } else { // Scalar or rational |
| 367 var width = ExifEncoder.getComponentWidth(tag); | 367 var width = ExifEncoder.getComponentWidth(tag); |
| 368 | 368 |
| 369 function writeComponent(value, signed) { | 369 var writeComponent = function(value, signed) { |
| 370 if (width == 8) { | 370 if (width == 8) { |
| 371 bw.writeScalar(value[0], 4, signed); | 371 bw.writeScalar(value[0], 4, signed); |
| 372 bw.writeScalar(value[1], 4, signed); | 372 bw.writeScalar(value[1], 4, signed); |
| 373 } else { | 373 } else { |
| 374 bw.writeScalar(value, width, signed); | 374 bw.writeScalar(value, width, signed); |
| 375 } | 375 } |
| 376 } | 376 }; |
| 377 | 377 |
| 378 var signed = (tag.format == 9 || tag.format == 10); | 378 var signed = (tag.format == 9 || tag.format == 10); |
| 379 if (tag.componentCount == 1) { | 379 if (tag.componentCount == 1) { |
| 380 writeComponent(tag.value, signed); | 380 writeComponent(tag.value, signed); |
| 381 } else { | 381 } else { |
| 382 for (var i = 0; i != tag.componentCount; i++) { | 382 for (var i = 0; i != tag.componentCount; i++) { |
| 383 writeComponent(tag.value[i], signed); | 383 writeComponent(tag.value[i], signed); |
| 384 } | 384 } |
| 385 } | 385 } |
| 386 } | 386 } |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 }; | 558 }; |
| 559 | 559 |
| 560 /** | 560 /** |
| 561 * Check if every forward has been resolved, throw and error if not. | 561 * Check if every forward has been resolved, throw and error if not. |
| 562 */ | 562 */ |
| 563 ByteWriter.prototype.checkResolved = function() { | 563 ByteWriter.prototype.checkResolved = function() { |
| 564 for (var key in this.forwards_) { | 564 for (var key in this.forwards_) { |
| 565 throw new Error('Unresolved forward pointer ' + key.toString(16)); | 565 throw new Error('Unresolved forward pointer ' + key.toString(16)); |
| 566 } | 566 } |
| 567 }; | 567 }; |
| OLD | NEW |