truthseeker
truthseeker

Reputation: 1256

IDirectDrawSurface7::Blt stretch method

Which stretching method is used when source and destination surfaces of IDirectDrawSurface7::Blt method have different sizes ? Obviously when destination rectangle is smaller than source we can calculate destination pixel color by various methods - randomly choosing one of neighbouring pixels, calculating arithmetic mean or weighted arithmetic mean of neighbouring pixels. When destination rectangle is larger than source we can use linear interpolation, bicubic interpolation, lanczos method. How can I influence the quality of output when calling Blt method ? Its ideal for source and destination to have same sizes but sometimes its not possible. When doing 2D graphics for example I have png image on disk only for one supported screen resolution.

Upvotes: 0

Views: 533

Answers (1)

Ross Ridge
Ross Ridge

Reputation: 39621

Whether or not Blt does any filtering when the source and destination rectangles aren't the same size is hardware dependent. What algorithm, if any, is used is hardware dependent. There's very little control over what happens, although you can request that the output be filtered in the Y direction.

From the July 2000 Platform SDK DirectX documentation, "Blitting with Blt" topic:

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.

If you want more control over how the scaling is performed you either going to have to scale it yourself, or use Direct3D.

Upvotes: 1

Related Questions