| 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 /** | 5 /** |
| 6 * A namespace class for image encoding functions. All methods are static. | 6 * A namespace class for image encoding functions. All methods are static. |
| 7 */ | 7 */ |
| 8 function ImageEncoder() {} | 8 function ImageEncoder() {} |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 } | 162 } |
| 163 return array.buffer; | 163 return array.buffer; |
| 164 }; | 164 }; |
| 165 | 165 |
| 166 /** | 166 /** |
| 167 * A base class for a metadata encoder. | 167 * A base class for a metadata encoder. |
| 168 * | 168 * |
| 169 * Serves as a default metadata encoder for images that none of the metadata | 169 * Serves as a default metadata encoder for images that none of the metadata |
| 170 * parsers recognized. | 170 * parsers recognized. |
| 171 * | 171 * |
| 172 * @param {Object} original_metadata Starting metadata. |
| 172 * @constructor | 173 * @constructor |
| 173 * @param {Object} original_metadata Starting metadata. | |
| 174 */ | 174 */ |
| 175 ImageEncoder.MetadataEncoder = function(original_metadata) { | 175 ImageEncoder.MetadataEncoder = function(original_metadata) { |
| 176 this.metadata_ = ImageUtil.deepCopy(original_metadata) || {}; | 176 this.metadata_ = ImageUtil.deepCopy(original_metadata) || {}; |
| 177 if (this.metadata_.mimeType != 'image/jpeg') { | 177 if (this.metadata_.mimeType != 'image/jpeg') { |
| 178 // Chrome can only encode JPEG and PNG. Force PNG mime type so that we | 178 // Chrome can only encode JPEG and PNG. Force PNG mime type so that we |
| 179 // can save to file and generate a thumbnail. | 179 // can save to file and generate a thumbnail. |
| 180 this.metadata_.mimeType = 'image/png'; | 180 this.metadata_.mimeType = 'image/png'; |
| 181 } | 181 } |
| 182 }; | 182 }; |
| 183 | 183 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 findInsertionRange = function(encodedImage) { return {from: 0, to: 0} }; | 217 findInsertionRange = function(encodedImage) { return {from: 0, to: 0} }; |
| 218 | 218 |
| 219 /** | 219 /** |
| 220 * Return serialized metadata ready to write to an image file. | 220 * Return serialized metadata ready to write to an image file. |
| 221 * The return type is optimized for passing to Blob.append. | 221 * The return type is optimized for passing to Blob.append. |
| 222 * @return {ArrayBuffer} //TODO(JSDOC). | 222 * @return {ArrayBuffer} //TODO(JSDOC). |
| 223 */ | 223 */ |
| 224 ImageEncoder.MetadataEncoder.prototype.encode = function() { | 224 ImageEncoder.MetadataEncoder.prototype.encode = function() { |
| 225 return new Uint8Array(0).buffer; | 225 return new Uint8Array(0).buffer; |
| 226 }; | 226 }; |
| OLD | NEW |