JavaFX 8 Canvas Snapshot with alpha

前端 未结 1 1669
傲寒
傲寒 2021-01-18 12:40

I am currently working on a paint program (similar to Gimp and Photoshop) and in order to do that, I will need layers. I created a class called JImage which has a Arra

相关标签:
1条回答
  • 2021-01-18 13:08

    Set the fill for your SnapshotParameters to Color.TRANSPARENT before you take a snapshot.

    SnapshotParameters params = new SnapshotParameters();
    params.setFill(Color.TRANSPARENT);
    Image snapshot = currLayer.snapshot(params, null);
    

    From the javadoc:

    Sets the fill to the specified value. This is used to fill the entire image being rendered prior to rendering the node. A value of null indicates that the color white should be used for the fill. The default value is null.

    0 讨论(0)
提交回复
热议问题