Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which is the fastest way to show an image? #615

Open
ferronsnicola opened this issue Oct 28, 2022 · 2 comments
Open

Which is the fastest way to show an image? #615

ferronsnicola opened this issue Oct 28, 2022 · 2 comments

Comments

@ferronsnicola
Copy link

Hi, I am trying to view the processed image in an html page (using electron and react), i know that there is a toDataUrl() method that transform the image in a string that could be renderized by the browser, but it is super slow (for a 1500x2000px image, it takes about 2 seconds) and not usable for my needs.
Is there a faster way to do that?
Thanks in advance,
Nicola

@targos
Copy link
Member

targos commented Oct 29, 2022

You can have a canvas in your page and draw into it. See the implementation of getCanvas for example:

/**
* Creates a new canvas element and draw the image inside it
* @memberof Image
* @instance
* @return {Canvas}
*/
getCanvas() {
const data = new ImageData(
this.getRGBAData({ clamped: true }),
this.width,
this.height,
);
let canvas = createCanvas(this.width, this.height);
let ctx = canvas.getContext('2d');
ctx.putImageData(data, 0, 0);
return canvas;
},
};

@wc-orbis
Copy link

Has anyone found an alternative method to using canvas? I am using this library (which has been fantastic so far!) for 16 bit images, so using canvas is unfortunately not something I can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants