How to perform high quality bitmap scaling in Direct2D?
Asked Answered
K

1

5

I am trying to move an application from GDI+ to Direct2D for performance reasons.

Perviously I was using StretchBlt() in HALFTONE mode which gives great, but slow results.

Now I am drawing in Direct2D with RenderTarget->DrawBitmap() but it only has two modes, LINEAR and NEAREST_NEIGHBOR, neither which are very good. LINEAR is better but still produces awful artifacts.

Does Direct2D have any high quality scaling options? If not, am I better off sticking with GDI or is there another option? This is a Windows application running in a window with various Win32 controls.

Kicker answered 27/1, 2013 at 21:6 Comment(0)
M
8

Direct2D 1.0 only supported linear and nearest-neighbor interpolation. Direct2D 1.1 adds four additional interpolation algorithms. These are available through the new device context render target (ID2D1DeviceContext) and its DrawBitmap and DrawImage methods. Have a look at the D2D1_INTERPOLATION_MODE enum:

http://msdn.com/library/hh447004.aspx

Mellon answered 28/1, 2013 at 0:28 Comment(3)
If I recall, 1.1 is for Windows 8, with Windows 7 support in a patch and no support for Vista? So I'm out of luck if I want to support a wide range of systems.Kicker
Direct2D 1.1 is available on Windows 7 and 8 as well as Windows Phone 8 (unofficially). Unfortunately if you need support for Windows Vista you’re stuck with Direct2D 1.0.Mellon
Alternatively, you can also use the Windows Imaging Component to scale images. WIC works exceedingly well with both Direct2D 1.0 and 1.1 and is supported as far back as Windows XP. msdn.com/library/ee719810.aspxMellon

© 2022 - 2024 — McMap. All rights reserved.