我已经编写了一个将图表保存为图像的功能。我已经提到了我编写的代码: HTML:
Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(CSSImageValue or HTMLImageElement or SVGImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap or OffscreenCanvas)'
at saveChart1 (generatedContent:310)
at HTMLSpanElement.onclick
Javescript:
public void floodFill(Bitmap bitmap, Point point, int i, int j) {
int k = bitmap.getWidth();
int l = bitmap.getHeight();
if (i != j) {
LinkedList linkedlist = new LinkedList();
do {
int i1 = point.x;
int j1;
for (j1 = point.y; i1 > 0 && !isBlack(bitmap.getPixel(i1 - 1, j1),j); i1--) {
}
boolean flag = false;
boolean flag1 = false;
while (i1 < k && !isBlack(bitmap.getPixel(i1, j1), j)) {
bitmap.setPixel(i1, j1, j); //main
if (!flag && !isBlack(bitmap.getPixel(i1, j1 - 1), j)) {
linkedlist.add(new Point(i1, j1 - 1));
flag = true;
} else if (flag && isBlack(bitmap.getPixel(i1, j1 - 1), j)) {
flag = false;
}
if (!flag1 && !isBlack(bitmap.getPixel(i1, j1 + 1), j)) {
linkedlist.add(new Point(i1, j1 + 1));
flag1 = true;
} else if (flag1 && j1 < l - 1 && isBlack(bitmap.getPixel(i1, j1 + 1), j)) {
flag1 = false;
}
i1++;
}
point = (Point) linkedlist.poll();
} while (point != null);
}
// maybe even reorder the conditions:
// If conditions are equal hard to compute:
// for || always do the mostlikely satisfied condition to the front
// for && always do the mostlikely to fail condition to the front
private boolean isBlack(int i, int j) {
float r= Color.red(i);
float g= Color.green(i);
float b= Color.blue(i);
retrun (r == g && g == b && r < 100 || i == j) ;
}
当我点击保存按钮然后得到以下提到的错误:
e.getCause().getMessage()
任何人都可以建议我在哪里做错了。