canvas需要gpu_使用GPU画布和TCanvas.DrawBitmap时低质量的缩小插值

bd96500e110b49cbb3cd949968f18be7.png

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:

P6Gq6.png

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

8GBOQ.png

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.

解决方案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.

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).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值