IDirectDrawSurface7::Blt 拉伸法
IDirectDrawSurface7::Blt stretch method
当IDirectDrawSurface7::Blt方法的源表面和目的表面尺寸不同时,使用哪种拉伸方法?显然,当目标矩形小于源矩形时,我们可以通过多种方法计算目标像素颜色——随机选择一个相邻像素,计算相邻像素的算术平均值或加权算术平均值。当目标矩形大于源矩形时,我们可以使用线性插值、双三次插值、lanczos 方法。调用 Blt 方法时如何影响输出质量?源和目标具有相同的大小是理想的,但有时这是不可能的。例如,在做 2D 图形时,我在磁盘上只有一种支持的屏幕分辨率的 png 图像。
当源矩形和目标矩形大小不同时,Blt 是否进行任何过滤取决于硬件。使用什么算法(如果有的话)取决于硬件。尽管您可以请求在 Y 方向过滤输出,但几乎无法控制发生的事情。
摘自 2000 年 7 月的 Platform SDK DirectX 文档,“使用 Blt 进行 Blitting”主题:
Hardware acceleration for scaling depends on the DDFXCAPS_BLT* flags in the dwFXCaps member of the DDCAPS structure for the device. If, for example, a device has the DDFXCAPS_BLTSTRETCHXN capability but not DDFXCAPS_BLTSTRETCHX, it can assist when the x-axis of the source rectangle is being multiplied by a whole number but not when non-integral (arbitrary) scaling is being done.
Devices might also support arithmetic scaling, which is scaling by interpolation rather than simple multiplication or deletion of pixels. For instance, if an axis was being increased by one-third, the pixels would be recolored to provide a closer approximation to the original image than would be produced by the doubling of every third pixel on that axis.
Applications cannot control the type of scaling done by the driver, except by setting the DDBLTFX_ARITHSTRETCHY flag in the dwDDFX member of the DDBLTFX structure passed to Blt. This flag requests that arithmetic stretching be done on the y-axis. Arithmetic stretching on the x-axis and arithmetic shrinking are not currently supported in the DirectDraw API, but a driver may perform them by default.
如果您想更好地控制缩放的执行方式,您要么必须自己缩放,要么使用 Direct3D。
当IDirectDrawSurface7::Blt方法的源表面和目的表面尺寸不同时,使用哪种拉伸方法?显然,当目标矩形小于源矩形时,我们可以通过多种方法计算目标像素颜色——随机选择一个相邻像素,计算相邻像素的算术平均值或加权算术平均值。当目标矩形大于源矩形时,我们可以使用线性插值、双三次插值、lanczos 方法。调用 Blt 方法时如何影响输出质量?源和目标具有相同的大小是理想的,但有时这是不可能的。例如,在做 2D 图形时,我在磁盘上只有一种支持的屏幕分辨率的 png 图像。
当源矩形和目标矩形大小不同时,Blt 是否进行任何过滤取决于硬件。使用什么算法(如果有的话)取决于硬件。尽管您可以请求在 Y 方向过滤输出,但几乎无法控制发生的事情。
摘自 2000 年 7 月的 Platform SDK DirectX 文档,“使用 Blt 进行 Blitting”主题:
Hardware acceleration for scaling depends on the DDFXCAPS_BLT* flags in the dwFXCaps member of the DDCAPS structure for the device. If, for example, a device has the DDFXCAPS_BLTSTRETCHXN capability but not DDFXCAPS_BLTSTRETCHX, it can assist when the x-axis of the source rectangle is being multiplied by a whole number but not when non-integral (arbitrary) scaling is being done.
Devices might also support arithmetic scaling, which is scaling by interpolation rather than simple multiplication or deletion of pixels. For instance, if an axis was being increased by one-third, the pixels would be recolored to provide a closer approximation to the original image than would be produced by the doubling of every third pixel on that axis.
Applications cannot control the type of scaling done by the driver, except by setting the DDBLTFX_ARITHSTRETCHY flag in the dwDDFX member of the DDBLTFX structure passed to Blt. This flag requests that arithmetic stretching be done on the y-axis. Arithmetic stretching on the x-axis and arithmetic shrinking are not currently supported in the DirectDraw API, but a driver may perform them by default.
如果您想更好地控制缩放的执行方式,您要么必须自己缩放,要么使用 Direct3D。