| <!DOCTYPE html> |
| <!-- |
| | Loading an image from a Blob created from a buffer in memory. |
| --> |
| <html> |
| <head> |
| <style> |
| div { |
| width: 500px; |
| height: 400px; |
| } |
| </style> |
| </head> |
| <body> |
| <div id='image'></div> |
| <script> |
| if (window.testRunner) { |
| window.testRunner.waitUntilDone(); |
| } |
| |
| var image_bytes = [ |
| 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, |
| 6, 0, 0, 0, 6, 8, 2, 0, 0, 0, 111, 174, 120, 31, 0, 0, 0, 3, 115, 66, |
| 73, 84, 8, 8, 8, 219, 225, 79, 224, 0, 0, 0, 25, 116, 69, 88, 116, 83, |
| 111, 102, 116, 119, 97, 114, 101, 0, 103, 110, 111, 109, 101, 45, 115, |
| 99, 114, 101, 101, 110, 115, 104, 111, 116, 239, 3, 191, 62, 0, 0, 0, |
| 36, 73, 68, 65, 84, 8, 153, 99, 252, 80, 238, 198, 128, 10, 88, 24, 24, |
| 24, 154, 119, 190, 132, 243, 107, 221, 197, 153, 24, 48, 0, 113, 66, |
| 140, 152, 198, 3, 0, 225, 21, 6, 103, 179, 203, 171, 64, 0, 0, 0, 0, |
| 73, 69, 78, 68, 174, 66, 96, 130]; |
| |
| // TODO(jsalvadorp): When TypedArray supports setting from a Javascript |
| // array, replace the following loop. |
| var image_array = new Uint8Array(image_bytes.length); |
| for (var i = 0; i < image_array.length; i++) { |
| image_array[i] = image_bytes[i]; |
| } |
| |
| var image_blob = new Blob([image_array.buffer]); |
| var image_url = URL.createObjectURL(image_blob); |
| |
| var image = new Image(); |
| image.onload = function() { |
| var cobalt = document.getElementById('image'); |
| cobalt.style.background = 'url(' + image_url + ')'; |
| |
| if (window.testRunner) { |
| window.testRunner.notifyDone(); |
| } |
| } |
| image.src = image_url; |
| </script> |
| </body> |
| </html> |