-1

I have built a JPanel which is painted based on a 2D array of data which the user can draw on.

I'm wondering if it is possible to somehow allow the user to upload a background picture, then set the size of the array based on the image to allow them to draw over it by filling in array cells. Then of course, rubbing out the colour in a cell should get back the original segement of the image.

Is this at all possible? I haven't found anything? I have the array at the moment and drawing using a MouseMotionListener but can't seem to find a way to set the 2D array size based on an image and then display it behind the 2d array.

4

1 回答 1

0

我想知道是否有可能以某种方式允许用户上传背景图片,然后根据图像设置数组的大小,以允许他们通过填充数组单元格来绘制它。然后,当然,擦掉单元格中的颜色应该会恢复图像的原始片段。

是的,这绝对是可能的。与所有编程一样,关键是将一个大问题分解为小步骤,然后尝试解决每一个小步骤,一次一个。

这是可能吗?我什么都没找到?

您的问题过于广泛,无法通过在线搜索找到完整甚至部分的解决方案。同样,您可以为每个单独的步骤找到解决方案,但您首先必须创建您的步骤。完成此操作后,您将很容易为您可能遇到的每个步骤找到教程和解决方案。

我目前有数组并使用 MouseMotionListener 进行绘图,但似乎找不到基于图像设置 2D 数组大小然后将其显示在 2d 数组后面的方法。

向我们展示你拥有什么以及你被困在哪里。我们需要代码。请注意,您的问题越具体,我们的答案通常就越好、越具体。您当前的问题简而言之“这可能吗”,答案当然是“是”,但除此之外,如果不知道更多关于您可能会被卡住的地方,我不确定还能说什么.

于 2013-08-09T23:02:10.823 回答