MCPcopy Index your code
hub / github.com/microsoft/SandDance / getImageData

Function getImageData

docs/app/js/sanddance-app.js:57520–57537  ·  view source on GitHub ↗
(image)

Source from the content-addressed store, hash-verified

57518 return format;
57519}
57520function getImageData(image) {
57521 switch(getImageType(image)){
57522 case "data":
57523 return image;
57524 case "image":
57525 case "imagebitmap":
57526 var canvas = document.createElement("canvas");
57527 var context = canvas.getContext("2d");
57528 if (context) {
57529 canvas.width = image.width;
57530 canvas.height = image.height;
57531 context.drawImage(image, 0, 0);
57532 return context.getImageData(0, 0, image.width, image.height);
57533 }
57534 default:
57535 return (0, _assertDefault.default)(false);
57536 }
57537}
57538function getImageTypeOrNull(image) {
57539 if (typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) return "imagebitmap";
57540 if (typeof Image !== "undefined" && image instanceof Image) return "image";

Callers

nothing calls this directly

Calls 1

getImageTypeFunction · 0.70

Tested by

no test coverage detected