Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 79x 79x 79x 79x 79x 79x | import CesiumMath from "./Math.js";
/**
* Resizes an image to ensure both width and height are powers of 2.
* NOTE: The input image is resampled larger, rather than padded.
* The aspect ratio of the image may change.
*
* @param {HTMLImageElement|HTMLCanvasElement} image The image to be resized
* @returns {HTMLCanvasElement} A new canvas with the resized image drawn to it
*
* @private
*/
function resizeImageToNextPowerOfTwo(image) {
const canvas = document.createElement("canvas");
canvas.width = CesiumMath.nextPowerOfTwo(image.width);
canvas.height = CesiumMath.nextPowerOfTwo(image.height);
const canvasContext = canvas.getContext("2d");
canvasContext.drawImage(
image,
0,
0,
image.width,
image.height,
0,
0,
canvas.width,
canvas.height,
);
return canvas;
}
export default resizeImageToNextPowerOfTwo;
|