IMaker icon indicating copy to clipboard operation
IMaker copied to clipboard

[求助]——下载选中区域的图片功能

Open slince-zero opened this issue 1 year ago • 0 comments

目前,我已经完成点击‘截选按钮’ 出现一个可以拖动、拉伸的框框,但是下载选中区域的图片,这个功能遇到了一些问题。

问题如下:

图片和一些编辑操作都在 CenterBoard 组件中,所以在最外层的div里面写一个ref={imageContainerRef}>,可以很容易的拿到整个页面的dom元素,然后再借助 dom-to-image 这个库就可以实现下载。

但是,我将一个名为ScreenCapture 的组件放在了 CenterBoard 组件中,所以,我不知道应该怎么拿到选中区域的图片,希望有人可以帮我解决下这个问题。

I have currently implemented a feature where clicking on a 'crop button' creates a draggable and resizable box. However, I'm facing some issues with downloading the selected area of the image.

The problem is as follows:

Both the image and some editing operations are within the CenterBoard component. So, by adding a ref={imageContainerRef} to the outermost div, I can easily access the DOM elements of the entire page, and then with the help of the dom-to-image library, I can achieve the download functionality.

However, I have a component called ScreenCapture placed within the CenterBoard component. Therefore, I'm unsure how to access the image of the selected area. I hope someone can help me resolve this issue.

slince-zero avatar May 14 '24 09:05 slince-zero