Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Compatible A8 Render Targets Overview

This topic describes the basics of a compatible A8 render target, and provides examples of how to use it.

A compatible A8 render target is a compatible render target (ID2D1BitmapRenderTarget) that uses an A8 pixel format (DXGI_FORMAT_A8_UNORM). You can use a compatible A8 render target to improve the application's performance and provide smoother transitions during text animation. A compatible A8 render target is particular useful when you try to improve the following:

  • The frame rate of the application that renders text or anti-aliased geometry that includes only simple animations, such as translation, rotation, scale, or color changes.

  • The visual continuity of the application that stretches and diminshes text during an animation.

To create a compatible A8 render target, use the ID2D1RenderTarget::CreateCompatibleRenderTarget method together with the DXGI_FORMAT_A8_UNORM pixel format, and specify a returned compatible render target. For more information about pixel formats, see Supported Pixel Formats and Alpha Modes.

For example, to efficiently animate the text that is shown in the following screen shot, use a compatible A8 render target to cache the text as an opacity mask. Then, apply transformations to the opacity mask to achieve fast rendering results.

Screen shot of text to animate

The following code shows how to do this. It creates a compatible A8 render target, retrieves the bitmap from it, and then renders the bitmap by using FillOpacityMask.

    ID2D1BitmapRenderTarget *m_pOpacityRT;

        // Create the compatible render target using desiredPixelSize to avoid
        // blurriness issues caused by a fractional-pixel desiredSize.

        D2D1_PIXEL_FORMAT alphaOnlyFormat = D2D1::PixelFormat(

        hr = m_pRT->CreateCompatibleRenderTarget(

            D2D1_RECT_F destinationRect = D2D1::RectF(
                roundedOffset.x + opacityRTSize.width,
                roundedOffset.y + opacityRTSize.height

            ID2D1Bitmap *pBitmap = NULL;

            pBitmap->GetDpi(&dpiX, &dpiY);

            // The antialias mode must be set to D2D1_ANTIALIAS_MODE_ALIASED
            // for this method to succeed. We've set this mode already though
            // so no need to do it again.


Related topics

Direct2D Reference



© 2017 Microsoft