Low quality downscale interpolation when using a GPU canvas and TCanvas.DrawBitmap

倾然丶 夕夏残阳落幕 提交于 2019-12-11 16:32:14

问题


When setting Delphi to use a GPU canvas (FMX.Types.GlobalUseGPUCanvas := True), under windows and android there doesn't seem to be high quality downscale interpolation performed when calling TCanvas.DrawBitmap, instead the result looks pixelated (nearest neighbor scaler?).

Looking at the source code (FMX.Canvas.GPU.pas/DoDrawBitmap), the "HighSpeed" parameter is never used.

using TCanvas.DrawBitmap:

Using a software based bicubic scaler (a lot slower):

One would think that using the GPU would give access to a cheap (CPU-use wise) high quality scaler, but this does not seem to be the case.

Is there a way to access a good quality cross-platform hardware scaler using Delphi (or at least Delphi under Android)?

Edit:
The form's Quality property is set to "HighQuality" in these screenshots.


回答1:


Yes the HighSpeed is never used but that not mean their is no interpolation. on GPU the interpolation is made through Form.quality (HighPerformance / HighQuality)




回答2:


  1. GlobalUseGPUCanvas := True on Desktops always draws all controls without AA. So do not use it on desktop. On Android/iOS it's a default method.

  2. If you do not use GlobalUseGPUCanvas, but still have no AA. That is because of scaling - screen current global scale value. If scale is 3, you should prepare you image in Photoshop with 3x scale (3 times more resolution, and your image will be with smoothed).

This code if you draw an image in runtime with canvas (e.g. diagram):

if Scene <> nil then
  lScale := Scene.GetSceneScale
else
  lScale := 1;

fBitmap.BitmapScale := lScale;

fBitmap.SetSize(Ceil(Width * lScale), Ceil(Height * lScale) );

To see a real image size on your device, set TImage.Wrapmode to Original.

P.s. Btw if you need to draw primitives like lines, circles etc with antialiasing on Android/iOS - use this native draw solution (On Android/iOS, FMX draws primitives without AA (btw this does not apply to images, all images are with AA on all platforms).



来源:https://stackoverflow.com/questions/51157715/low-quality-downscale-interpolation-when-using-a-gpu-canvas-and-tcanvas-drawbitm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!