{"ScriptPreparationCode":"var\r\nnatrualWidth = 0,\r\nnaturalHeight = 0,\r\n\r\neleImg = document.createElement(\u0022img\u0022),\r\ncvsImg = document.createElement(\u0022canvas\u0022),\r\nbmpImg = null,\r\n\r\ncanvasEleImg = document.createElement(\u0022canvas\u0022),\r\ncanvasCvsImg = document.createElement(\u0022canvas\u0022),\r\ncanvasBmpImg = document.createElement(\u0022canvas\u0022),\r\n\r\nctxEleImg = canvasEleImg.getContext(\u00222d\u0022),\r\nctxCvsImg = canvasCvsImg.getContext(\u00222d\u0022),\r\nctxBmpImg = canvasBmpImg.getContext(\u00222d\u0022),\r\n\r\ndoneLoading = false;\r\n\r\ncanvasEleImg.width = canvasBmpImg.width = canvasCvsImg.width = 640;\r\ncanvasEleImg.height = canvasBmpImg.height = canvasCvsImg.height = 480;\r\n\r\neleImg.addEventListener(\u0022load\u0022, function()\r\n{\r\n\tcvsImg.width = naturalWidth = eleImg.naturalWidth;\r\n\tcvsImg.height = naturalHeight = eleImg.naturalHeight;\r\n\tcvsImg.getContext(\u00222d\u0022).drawImage(eleImg, 0, 0, natrualWidth, naturalHeight, 0, 0, natrualWidth, naturalHeight);\r\n\r\n\tPromise.all([\r\n\t\tcreateImageBitmap(img)\r\n\t]).then(function(images)\r\n\t{\r\n\t\timageBitmap = images[0];\r\n\r\n\t\tdoneLoading = true;\r\n\t}, false);\r\n});\r\neleImg.src = \u0022https://placekitten.com/200/300\u0022;","TestCases":[{"Name":"HTMLImageElement","Code":"if (doneLoading) ctxEleImg.drawImage(eleImg, 0, 0, natrualWidth, naturalHeight, 0, 0, natrualWidth, naturalHeight);","IsDeferred":false},{"Name":"HTMLCanvasElement","Code":"if (doneLoading) ctxCvsImg.drawImage(cvsImg, 0, 0, natrualWidth, naturalHeight, 0, 0, natrualWidth, naturalHeight);","IsDeferred":false},{"Name":"ImageBitmap","Code":"if (doneLoading) ctxBmpImg.drawImage(bmpImg, 0, 0, natrualWidth, naturalHeight, 0, 0, natrualWidth, naturalHeight);","IsDeferred":false}]}