Sdílet prostřednictvím


How to: Make a Texture with Masking

This article explains how to make a texture with a masking (transparency) layer using either .png or .bmp format files and the DirectX Texture Tool. The DirectX Texture Tool is one of the utilities included in the DirectX SDK.

To create a transparent texture using a .png file

  1. In a .png file editor, create or copy the image you wish to use for the texture, and set the transparency regions for the file.
  2. In the DirectX Texture tool, create a new texture that is the same size as the .png file. Choose a texture format that has an alpha channel, such as A8R8G8B8.
  3. In the DirectX Texture tool, click Open Onto This Surface and select the .png file.

The resulting texture in the DirectX Texture tool should contain the same image and transparency region as the .png file.

To create a transparent texture using a .bmp file

  1. In a bitmap file editor (such as Windows Paint), create or copy the image you wish to use for the texture to a bitmap (.bmp) file.
  2. Create a second "mask" bitmap file using white pixels where the texture is to be opaque, and black pixels where the texture is to be transparent.
  3. In the DirectX Texture tool, create a new texture that is the same size as the bitmap file. Choose a texture format that has an alpha channel, such as A8R8G8B8.
  4. In the DirectX Texture tool, click Open Onto This Surface and select the first bitmap file.
  5. In the DirectX Texture tool, click Open Onto Alpha Channel Of This Surface and select the second "mask" bitmap file.

The resulting texture in the DirectX Texture tool should contain the image from the first bitmap file and the transparency region from the second file.

See Also

Concepts

2D Graphics Overview

Tasks

How to: Draw a Masked Sprite over a Background