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 alpha values ranging from 0 to 255 due to antialias...
I googled and tried everything that I could... is this possible at all?
I was able to make this work, although it feels a bit hacky:
After this,
finalImage
can be drawn into aGC
withdrawImage
and the transparent parts will be respected.I made it by allocating an
ImageData
, making it transparent then creating theImage
from the data :This is how I did and it works:
To scale with transparency, I've found that I have to manually set the alpha byte array as shown below. So the alpha ends up with nearest-neighbor anti aliasing.