使用Java SWT绘制透明图像 [英] Drawing on a transparent image using Java SWT
本文介绍了使用Java SWT绘制透明图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何创建内存中完全透明的SWT图像,并在启用了抗锯齿的情况下在其上绘制黑线?
How do I create an in-memory fully transparent SWT image and draw a black line on it with antialias enabled?
我希望结果只包含黑色由于抗锯齿,alpha值范围从0到255 ...
I expect the result to include only black color and alpha values ranging from 0 to 255 due to antialias...
我用Google搜索并尝试了所有可能的东西......这有可能吗?
I googled and tried everything that I could... is this possible at all?
推荐答案
这就是我的工作方式,它起作用:
This is how I did and it works:
Image src = new Image(null, 16, 16);
ImageData imageData = src.getImageData();
imageData.transparentPixel = imageData.getPixel(0, 0);
src.dispose();
Image icon = new Image(null, imageData);
//draw on the icon with gc
这篇关于使用Java SWT绘制透明图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文