Blend

This sample demonstrates the alpha blend function of the PPE peripheral.

Requirements

For requirements, please refer to the Requirements.

Wiring

No physical connection is required in this sample.

Configurations

The following parameter can be changed to modify blending result.

Alpha Mask

Alpha mask function can be adjusted by changing following parameters in source image structure:

source.global_alpha_en = 0;  /* 0: Disable alpha mask, 1: Enable alpha mask */
source.global_alpha = 0xFF;  /* Value from 0 to 255 */

Color Key

Color key function can be adjusted by changing following parameters in source image structure:

source.color_key_en = 0;    /* 0: Disable color key, 1: Enable color key */
source.color_key_value = 0; /* Key value to be filtered */

Position Translation

Position translation function are determined in ppe_translate_t parameter:

ppe_translate_t position = {.x = 0,.y = 0};  /* Position translation */

Blend Mode

Blend mode can be adjusted by changing following parameter:

PPE_Blend(&source, &target, &trans, PPE_SRC_OVER_MODE); /* Blend mode */

Note

The following blend modes are supported:

  • PPE_SRC_OVER_MODE

  • PPE_BYPASS_MODE

Building and Downloading

For building and downloading, please refer to the Building and Downloading.

Experimental Verification

Blend Successfully

After the sample is executed, result from PPE will be compared with simulation data. Observing the following log in the DebugAnalyzer window indicates successful blending:

PPE blend test passed 0

Blend Failed

After the sample is executed, result from PPE will be compared with simulation data. Observing the following log in the DebugAnalyzer window indicates failed blending:

Data mismatch, expect 0x%40406427, actual 0x%12345678
PPE blend test failed {error code}

Description of {error code} can be found in PPE_ERR.

Code Overview

This section introduces the code and process description for initialization and corresponding function implementation in the sample.

Source Code Directory

The directories for project file and source code are as follows:

  • Project directory: sdk\samples\peripheral\ppe\blend\proj

  • Source code directory: sdk\samples\peripheral\ppe\blend\src

Initialization

The initialization process is included in PPE_test().

  1. Initialize data of foreground and background in ppe_buffer_t structures.

ppe_buffer_t target, source;
memset(&target, 0, sizeof(ppe_buffer_t));
memset(&source, 0, sizeof(ppe_buffer_t));
  1. Initialize ppe_buffer_t structures that contain information of foreground, color key and alpha mask are configured at the same time.

source.address = (uint32_t) source_buffer;
source.memory = source_buffer;
source.color_key_en = DISABLE;
source.color_key_value = 0;
source.global_alpha_en = 0;
source.global_alpha = 0xFF;
source.format = PPE_ABGR8888;
source.width = 64;
source.height = 64;
source.stride = source.width;
  1. Initialize ppe_buffer_t structures that contain information of background.

target.address = (uint32_t) target_buffer;
target.memory = target_buffer;
target.format = PPE_ABGR8888;
target.width = 64;
target.height = 64;
target.stride = target.width;
  1. After determining translation of foreground and blend mode, call API PPE_Blend() to start to blend.

ppe_translate_t trans = {.x = 0, .y = 0};
PPE_ERR err = PPE_Blend(&source, &target, &trans, PPE_SRC_OVER_MODE);

Functional Implementation

After PPE_Blend() is completed, result of PPE will be compared with simulation data. If any error occurs, false data will be displayed in DebugAnalyzer Tool as demonstrated in Experimental Verification.