tags:

views:

47

answers:

2

I am using following code 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.

A: 

You should first convert it to Greyed version before drawing it. GraphicsContext simply draws what you want it to draw.

Bragboy
@Bragboy thanks, so the detailed solution how to do it in my answer.
Vladimir
@Vladmir : Nice dude..
Bragboy
A: 

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

Vladimir