Tutorial
FM4, S6E2DH/S6E2DF/S6E2D5/S6E2D3 Series, 32-Bit Microcontroller, Graphic Driver User Manual, Doc. No. 002-04387 Rev. *A
41
6.5.7 Blending two surfaces
To blend an image with an alpha channel onto the existing store surface, we have to connect surfStore both as
destination (input) and store (output).
The second input surface is again surfSrc. It has to be reset because now it holds another image with just 8 bit alpha
values. Therefore MML_GDC_SURF_FORMAT_A8 has to be used. We define 255/0/0/255 as the constant color to
see the text in red. The alpha channel in the constant color definition has no effect, because it is defined by the
image!
// re-use the source surface for the text
mmlGdcSmResetSurfaceObject(surfSrc);
UTIL_SUCCESS(ret, mmlGdcSmAssignBuffer(surfSrc, textWidth, textHeight, MML_GDC_SURF_FORMAT_A8,
(
void
*)textAddr, 0));
UTIL_SUCCESS(ret, mmlGdcPeSurfColor(ctx, MML_GDC_PE_SRC, 255, 0, 0, 255));
UTIL_SUCCESS(ret, mmlGdcPeBindSurface(ctx, MML_GDC_PE_STORE | MML_GDC_PE_DST, surfStore));
UTIL_SUCCESS(ret, mmlGdcPeBlt(ctx, 50.0f, 70.0f));
Figure 16. Blended text
6.5.8 Bring it to the display
To see the surface on the display, we need a to create a display object by calling mmlGdcDispOpenDisplay. Beside
this a window is required using mmlGdcDispWinCreate. Finally our surfStore must be set to the window using
mmlGdcDispWinSetSurface and mmlGdcDispWinCommit activates the changes.
// set up the display
// complete the display params
dispParams.xResolution = 480;
dispParams.yResolution = 272;
UTIL_SUCCESS(ret, mmlGdcDispOpenDisplay(&dispParams, &display));
// create a display window and connect the store surface to it
// complete the windows params
winprop.width = dispParams.xResolution;
// horizontal display resolution
winprop.height = dispParams.yResolution;
// vertical display resolution
UTIL_SUCCESS(ret, mmlGdcDispWinCreate(display, &winprop, &win));
UTIL_SUCCESS(ret, mmlGdcDispWinSetSurface(win, MML_GDC_DISP_BUFF_TARGET_COLOR_BUFF,
surfStore));
UTIL_SUCCESS(ret, mmlGdcDispWinCommit(win));