我正在寻找一种快速简便的方法来在 SWT 画布中绘制任意颜色的像素。到目前为止,我正在使用类似的东西:
// initialization:
GC gc = new GC(canvas);
// inside the drawing loop:
Color cc = new Color(display, r, g, b);
gc.setForeground(cc);
gc.drawPoint(x, y);
cc.dispose();
这是非常可怕的缓慢。用像素填充 300x300 画布大约需要一秒半的时间。我可以在屏幕外创建一个图像,在其中设置像素,然后绘制图像。这会更快,但我特别想要在画布上逐像素绘制图像的渐变绘画效果。