| <!DOCTYPE HTML> |
| <html> |
| <head> |
| <style> |
| div { |
| width: 100px; |
| height: 100px; |
| margin: 10px; |
| display: inline-block; |
| } |
| img { |
| width: 100px; |
| height: 100px; |
| } |
| </style> |
| <head> |
| <body> |
| <script> |
| if (window.internals) |
| window.internals.settings.setImageSubsamplingEnabled(true); |
| |
| function createImage(color) { |
| var canvas = document.createElement("canvas"); |
| canvas.width = 1024 * 3; |
| canvas.height = 1024 * 3; |
| var ctx = canvas.getContext("2d"); |
| ctx.fillStyle = color; |
| ctx.fillRect(0, 0, canvas.width, canvas.height); |
| |
| var imgElement = document.createElement("img"); |
| imgElement.src = canvas.toDataURL("image/png"); |
| |
| var divElement = document.createElement("div"); |
| divElement.appendChild(imgElement); |
| document.body.appendChild(divElement); |
| } |
| |
| createImage("red"); |
| createImage("green"); |
| createImage("blue"); |
| </script> |
| </body> |
| </html> |