透明イメージを作成し、透明/半透明ピクセルを含む別のイメージを描画しようとしています。画像が追加された後、半透明のピクセルは、色とアルファの混合であるのに比べて白に設定されます。これにより、画像の周りに白い輪郭ができます。SWT透明ピクセルが白に変更されました
画像は透明なピクセルを持つToolItemとしてToolBarに表示する必要があります。
透過ピクセルを白に変更せずに透明画像を描画することはできますか?
オーバーレイ画像
処理された画像
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setSize(285,305);
// Create a transparent image
final Image transparentImage = new Image(null, 256, 256);
final ImageData imageData = transparentImage.getImageData();
imageData.transparentPixel = imageData.getPixel(0, 0);
transparentImage.dispose();
// Create an image with the transparent data
final Image processedImage = new Image(Display.getCurrent(),
imageData);
// Get the image to draw onto the transparent image
final Image overlayImage = new Image(display, "overlay_image.png");
final GC imageGC = new GC(processedImage);
imageGC.setAntialias(SWT.ON);
imageGC.drawImage(overlayImage, 0, 0);
imageGC.dispose();
// Create the components and add the image
final ToolBar toolBar = new ToolBar(shell, SWT.FLAT | SWT.BORDER);
final ToolItem item = new ToolItem(toolBar, SWT.NONE);
item.setImage(processedImage);
toolBar.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
overlayImage.dispose();
display.dispose();