使用GPU画布和TCanvas.DrawBitmap时低质量的缩小插值 [英] Low quality downscale interpolation when using a GPU canvas and TCanvas.DrawBitmap

查看:197
本文介绍了使用GPU画布和TCanvas.DrawBitmap时低质量的缩小插值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将Delphi设置为使用GPU画布(FMX.Types.GlobalUseGPUCanvas:= True)时,在Windows和android下,调用TCanvas.DrawBitmap时似乎没有执行高质量的低比例插值,而是结果看起来像是像素化(最近的邻居缩放器?).

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

查看源代码(FMX.Canvas.GPU.pas/DoDrawBitmap),从不使用"HighSpeed"参数.

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

使用TCanvas.DrawBitmap:

using TCanvas.DrawBitmap:

使用基于软件的双三次缩放器(速度要慢得多):

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

人们会认为,使用GPU可以访问便宜的(高质量的CPU使用)缩放器,但事实并非如此.

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.

是否可以使用Delphi(或至少在Android下为Delphi)访问高质量的跨平台硬件缩放器?

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


在这些屏幕截图中,表单的质量"属性设置为高质量".


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

推荐答案

  1. GlobalUseGPUCanvas:=在桌面上为True始终绘制不带AA的所有控件.因此,请勿在桌面上使用它.在Android/iOS上,这是默认方法.

  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.

如果您不使用GlobalUseGPUCanvas,但仍然没有AA.那是因为缩放-屏幕当前的全局缩放值. 如果比例为3,则应在Photoshop中以3倍的比例准备图像(分辨率提高3倍,并且图像将变得平滑).

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

要查看设备上的实际图像大小,请将TImage.Wrapmode设置为Original.

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

P.s.顺便说一句,如果您需要在Android/iOS上使用抗锯齿来绘制线,圆等图元,请使用

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

这篇关于使用GPU画布和TCanvas.DrawBitmap时低质量的缩小插值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆