Community
Participate
Working Groups
Currently the only way to scale an Image is to use the ImageData.scaleTo() method. However, the scaling quality provided by this implementation is not good. Also Since ImageData is a java side object it is not possible to provide an implementation that takes the advantage of native scaling. I would like to suggest a new constructor to the Image that takes another source Image and a target Size and possibly scaling hint. SWT implementations in turn can implement the constructor using native algorithms which will be higher quality and better performant then the current scaleTo implementation. Also please note that this is an enhancement that is also required by the eSWT project.
What about this: Image imageSrc = new Image(display, fileName); Rectangle rect = imageSrc.getBounds(); Image imageDst = new Image(display, rect.width * 2, rect.height * 2); GC gc = new GC(imageDst); gc.drawImage(imageSrc, 0, 0, rect.width, rect.height, 0, 0,rect.width * 2, rect.height * 2); gc.dispose(); This will use native scalling. Does it work for you ?
I would like us to have more control over the quality of the scale. With the GC solution, there is no such control. In S60, at least, the quality of the scale performed with the GC defaults to "low & quick" a.k.a. "nearest neighbour" scaling. With the new API addition we could hint (by declaring the param as hint we do not force all platform to conform) the desired scale quality & speed: - high & slow - nearest neighbour (quality param SWT.MAX ?) - medium - bilinear (quality param SWT.DEFAULT ?) - low & quick - bicubic (quality param SWT.MIN ?) The new API, I believe (personal opinion) is clearer and easier to find.
You have this control in the current API already. Before drawing the image with the GC you need to call setAdvance(true) and setInterpolation() with one of the following: SWT.DEFAULT (Gdip.InterpolationModeDefault), SWT.NONE (Gdip.InterpolationModeNearestNeighbor), SWT.LOW (Gdip.InterpolationModeLowQuality), SWT.HIGH (Gdip.InterpolationModeHighQuality). Closing as works for me. Agreed ?
I have failed to spot that. Thank you.