mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-18 11:39:08 +00:00
Style nitz
This commit is contained in:
@@ -28,11 +28,12 @@ export default class App extends Component<Props, State> {
|
|||||||
private async getImageData(bitmap: ImageBitmap): Promise<ImageData> {
|
private async getImageData(bitmap: ImageBitmap): Promise<ImageData> {
|
||||||
// Make canvas same size as image
|
// Make canvas same size as image
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
[canvas.width, canvas.height] = [bitmap.width, bitmap.height];
|
canvas.width = bitmap.width;
|
||||||
|
canvas.height = bitmap.height;
|
||||||
// Draw image onto canvas
|
// Draw image onto canvas
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
throw new Error("Could not create canvas contex");
|
throw new Error("Could not create canvas context");
|
||||||
}
|
}
|
||||||
ctx.drawImage(bitmap, 0, 0);
|
ctx.drawImage(bitmap, 0, 0);
|
||||||
return ctx.getImageData(0, 0, bitmap.width, bitmap.height);
|
return ctx.getImageData(0, 0, bitmap.width, bitmap.height);
|
||||||
|
|||||||
Reference in New Issue
Block a user