How to draw image in gray in SWT
I am using following c开发者_如何学Pythonode to draw scaled image in PaintListener.
e.gc.drawImage(image,
0, 0, w, h,
0, 0, scaledWidth, scaledHeight
);
I want to draw image in gray color.
What could be done for that? Does drawImage support some special parameters for that or I should better prepare and convert original image to be grayed.
You should first convert it to Greyed version before drawing it. GraphicsContext simply draws what you want it to draw.
I need to convert it either to greyed-out/disabled using Image class:
greyed = new Image(e.display, image, SWT.IMAGE_GRAY);
e.gc.drawImage(greyed,
0, 0, w, h,
0, 0, scaledWidth, scaledHeight
);
SWT.IMAGE_DISABLE
also can be used instead of SWT.IMAGE_GRAY
精彩评论