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 //TODO(JSDOC) | 10 //TODO(JSDOC) |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 149 } |
150 return array.buffer; | 150 return array.buffer; |
151 }; | 151 }; |
152 | 152 |
153 /** | 153 /** |
154 * A base class for a metadata encoder. | 154 * A base class for a metadata encoder. |
155 * | 155 * |
156 * Serves as a default metadata encoder for images that none of the metadata | 156 * Serves as a default metadata encoder for images that none of the metadata |
157 * parsers recognized. | 157 * parsers recognized. |
158 * | 158 * |
| 159 * @constructor |
159 * @param {Object} original_metadata Starting metadata. | 160 * @param {Object} original_metadata Starting metadata. |
160 */ | 161 */ |
161 ImageEncoder.MetadataEncoder = function(original_metadata) { | 162 ImageEncoder.MetadataEncoder = function(original_metadata) { |
162 this.metadata_ = ImageUtil.deepCopy(original_metadata) || {}; | 163 this.metadata_ = ImageUtil.deepCopy(original_metadata) || {}; |
163 if (this.metadata_.mimeType != 'image/jpeg') { | 164 if (this.metadata_.mimeType != 'image/jpeg') { |
164 // Chrome can only encode JPEG and PNG. Force PNG mime type so that we | 165 // Chrome can only encode JPEG and PNG. Force PNG mime type so that we |
165 // can save to file and generate a thumbnail. | 166 // can save to file and generate a thumbnail. |
166 this.metadata_.mimeType = 'image/png'; | 167 this.metadata_.mimeType = 'image/png'; |
167 } | 168 } |
168 }; | 169 }; |
(...skipping 30 matching lines...) Expand all Loading... |
199 findInsertionRange = function(encodedImage) { return {from: 0, to: 0} }; | 200 findInsertionRange = function(encodedImage) { return {from: 0, to: 0} }; |
200 | 201 |
201 /** | 202 /** |
202 * Return serialized metadata ready to write to an image file. | 203 * Return serialized metadata ready to write to an image file. |
203 * The return type is optimized for passing to Blob.append. | 204 * The return type is optimized for passing to Blob.append. |
204 * @return {ArrayBuffer} //TODO(JSDOC) | 205 * @return {ArrayBuffer} //TODO(JSDOC) |
205 */ | 206 */ |
206 ImageEncoder.MetadataEncoder.prototype.encode = function() { | 207 ImageEncoder.MetadataEncoder.prototype.encode = function() { |
207 return new Uint8Array(0).buffer; | 208 return new Uint8Array(0).buffer; |
208 }; | 209 }; |
OLD | NEW |