iv-viewer icon indicating copy to clipboard operation
iv-viewer copied to clipboard

Canvas support?

Open s4m0r4m4 opened this issue 5 years ago • 4 comments

Hello! I think the answer is "no", but I wanted to check - does iv-viewer support zoom/pan on canvas images? For instance, if I have an HTMLCanvasElement, can I pass that to iv-viewer rather than an html image element?

Great library, thank you!

s4m0r4m4 avatar Jun 23 '20 15:06 s4m0r4m4

Howdy, just checking on this. Canvas support would be an awesome feature!

s4m0r4m4 avatar Jul 24 '20 15:07 s4m0r4m4

@s-yadav, I just wanted to check in and get your thoughts on this issue. Thanks!

s4m0r4m4 avatar Aug 31 '20 14:08 s4m0r4m4

Hey, @s4m0r4m4. Sorry missed replying earlier on this. Currently, it does not support canvas. I would like to understand the use case for HTMLCanvasElement.

Ideally, you can get the data URL from canvas canvas.toDataURL() and pass the data URL as img url on the load method. https://github.com/s-yadav/iv-viewer#instance-methods

s-yadav avatar Aug 31 '20 15:08 s-yadav

Hello! My use case is that I have very large images (~200-400MB) that are sent to my app via websocket. I can't afford to render these in the main thread (it locks up the UI for too long!), so I am using a webworker to render that image in an offscreen canvas, along with rendering other items in the canvas.

To use your canvas.toDataURL() approach, I would have to run that in the worker and send the data URL back to the main thread and then pass it to iv-viewer. That data URL will be quite large, so there will be a performance hit.

It's probably not a good use case for this library, but I figured I would check to see perhaps there was a solution I was missing. Thanks for your reponse!

s4m0r4m4 avatar Sep 02 '20 12:09 s4m0r4m4