Drawing on a transparent image using Java SWT

前端 未结 4 1821
天涯浪人
天涯浪人 2021-01-04 12:08

How do I create an in-memory fully transparent SWT image and draw a black line on it with antialias enabled?

I expect the result to include only black color and alph

4条回答
  •  耶瑟儿~
    2021-01-04 13:03

    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
    

提交回复
热议问题